D
Daniel Berger
Help a guy out who got B's and C's in math classes in college:
Ruby 1.8.4 on Solaris 10:
irb(main):013:0> -1234567890987654321.remainder(13731)
=3D> -6966
irb(main):014:0> -1234567890987654321.remainder(13731.24)
=3D> -9906.22531493148
irb(main):015:0> -1234567890987654321.modulo(13731)
=3D> 6765
irb(main):016:0> -1234567890987654321.modulo(13731.24)
=3D> 3825.01468506852
Basically, I'm trying to figure out the nuances of Bignum#remainder vs=20
Bignum#modulo. To confuse myself even further K&R (2nd ed, p. 41) says =
you=20
can't do modulus on double or long, and that the sign result is machine=20
dependent for negative operands.
Can someone explain the subtleties of this to me (or point me to a link =
that=20
does)? An archive search didn't reveal anything obvious.
Perhaps the documentation in bignum.c needs further exposition? Or =
should I=20
just *know* this?
Thanks,
Dan
PS - I did try to read over the bigdivrem() private function in bignum.c =
but,=20
like, whoa.
This communication is the property of Qwest and may contain confidential =
or
privileged information. Unauthorized use of this communication is =
strictly=20
prohibited and may be unlawful. If you have received this communication =
in error, please immediately notify the sender by reply e-mail and =
destroy=20
all copies of the communication and any attachments.
Ruby 1.8.4 on Solaris 10:
irb(main):013:0> -1234567890987654321.remainder(13731)
=3D> -6966
irb(main):014:0> -1234567890987654321.remainder(13731.24)
=3D> -9906.22531493148
irb(main):015:0> -1234567890987654321.modulo(13731)
=3D> 6765
irb(main):016:0> -1234567890987654321.modulo(13731.24)
=3D> 3825.01468506852
Basically, I'm trying to figure out the nuances of Bignum#remainder vs=20
Bignum#modulo. To confuse myself even further K&R (2nd ed, p. 41) says =
you=20
can't do modulus on double or long, and that the sign result is machine=20
dependent for negative operands.
Can someone explain the subtleties of this to me (or point me to a link =
that=20
does)? An archive search didn't reveal anything obvious.
Perhaps the documentation in bignum.c needs further exposition? Or =
should I=20
just *know* this?
Thanks,
Dan
PS - I did try to read over the bigdivrem() private function in bignum.c =
but,=20
like, whoa.
This communication is the property of Qwest and may contain confidential =
or
privileged information. Unauthorized use of this communication is =
strictly=20
prohibited and may be unlawful. If you have received this communication =
in error, please immediately notify the sender by reply e-mail and =
destroy=20
all copies of the communication and any attachments.