Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

round

Name: Anonymous 2007-05-17 11:03 ID:ewt37wAw

Prelude> round 0.5
0
Prelude> round 1.5
2
Prelude> round 2.5
2
Prelude> round 3.5
4


WHAT THE FUCK

Name: Anonymous 2007-05-20 1:39 ID:cz/n9Z0X

>>15
Dude, I was taught in the local equivalent of grade school that 0.5 rounds _up_ by convention.

Then again, 0.5 (and 1.5, 2.5 etc) are those numbers that you cannot have exactly using a floating-point representation. So in financial code it's better to use an epsilon-sensitive comparison thing and call floor or ceil by hand. ... actually, in financial code it's best not to use floating point types at all.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List