mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
I found that while rounding negative numbers, the sign is kept no matter the result.. $round(-0.1,0) = -0

Joined: Mar 2008
Posts: 93
B
Babel fish
Online
Babel fish
B
Joined: Mar 2008
Posts: 93
With floating point numbers, theres a difference between +0 and -0 (which is the sign)
I'd expect this to be the case here, and I wouldn't want to "fix" that.

Does it break anything in particular for you?

Joined: Dec 2002
Posts: 252
T
Talon Offline OP
Fjord artisan
OP Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 252
mainly something that required the length of the number, which $len() returned 2 which baffled me, then I outputted the result and found that it was -0, a simple $calc() around $rand() fixes the issue tho.

Example:
$calc($round(-0.1,0))

Joined: Feb 2003
Posts: 2,812
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Numbers rounded to 0 decimal places are now integers, and -0 should be rounded to 0 with no sign. It breaks sorting, too, ie $sorttok or /window -s


Well. At least I won lunch.
Good philosophy, see good in bad, I like!

Link Copied to Clipboard