Re: Rounding mode
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>) |