There's more than one way to do things | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
So, which is the more common result? Unfortunately, there's no good answer. Hardware vendors choose different ways of implementing division, because division is complicated. Language specifications usually let the compiler go with whatever the underlying hardware does, for speed. Division with round-towards-zero (which can produce a negative remainder) is common in modern systems, but nobody is making you any guarantees. If getting consistent results across different platforms is important to you, you can always calculate the remainder by hand.
Of course, that costs you an extra multiply and subtract. I think it really comes down to how the rounding operation works. Precisely. In reply to Re: Re: Re: Modulus Inconsistencies (Or Calling all Mathematicians)
by no_slogan
|
|