• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Rounding mode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rounding mode


  • Subject: Re: Rounding mode
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 09 Dec 2012 20:49:47 +0100

Le 9 déc. 2012 à 13:17, Jan E. Schotsman <email@hidden> a écrit :

> Hello,
>
> I am using Xcode 3.1.3 on MacOSX 10.5.8
>
> I am trying to use  fesetround()  and friends.
> c com.apple.compilers.gcc.4_2
> -std=gnu99
>
> In the debugger:
>
> int	savedRndMode = fegetround(); (savedRndMode= 0) (using _FE_TONEAREST)
>
> Expression window: (SInt32)0.7   0  (!!!)
>
> What am I missing?

I don't think the C standard specify that the current rounding mode should be used when converting a float to an int.

C Standard: 6.3.1.4
	• 1  When a finite value of real floating type is converted to an integer type other than _Bool, the fractional part is discarded (i.e., the value is truncated toward zero). If the value of the integral part cannot be represented by the integer type, the behavior is undefined.)

If you want to round a floating point value according to the current rounding mode, you should the rint() function.

-- Jean-Daniel





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


References: 
 >Rounding mode (From: "Jan E. Schotsman" <email@hidden>)

  • Prev by Date: Rounding mode
  • Next by Date: Re: Rounding mode
  • Previous by thread: Rounding mode
  • Next by thread: Re: Rounding mode
  • Index(es):
    • Date
    • Thread