floor(-0.5)

F

Francois Grieu

In ISO/IEC 9899:1999, it is unambiguous that floor(-0.5)
has the value -1 (converted to double).

Was this the case in earlier C standards?

Is anyone aware of an implementaton that has it wrong ?

Françosi Grieu
 
K

Keith Thompson

Francois Grieu said:
In ISO/IEC 9899:1999, it is unambiguous that floor(-0.5)
has the value -1 (converted to double).

Was this the case in earlier C standards?

C90 says:

The floor function returns the largest integral value not greater
than x, expressed as a double.

C99 says:

The floor functions return |_ x _|, expressed as a floating-point number.

where "|_" and "_|" are my crude rendition of the mathematical symbol
for the floor function.
Is anyone aware of an implementaton that has it wrong ?

I'm not -- and given that the function is called "floor", getting it
wrong (say, by rounding towards 0.0) would be a pretty dumb mistake.
 
F

Francois Grieu

Keith Thompson <[email protected]> said:
C90 says:

The floor function returns the largest integral value not greater
than x, expressed as a double.

Very clear indeed.

C99 says:

The floor functions return |_ x _|, expressed as a floating-point number.

where "|_" and "_|" are .. the mathematical symbol for the floor function.

And |_ x _| is defined in ?3.19 as
... "the greatest integer less than or equal to x.
Example: |_ 2.4 _| is 2, |_ -2.4 _| is -3."


Thanks for the C90 quote !

Francois Grieu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top