RE: Generating Modulo and Remainder Operations

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Alternatively, for integers you can use the % operator with unsigned
> numbers.  (If you need to work with signed numbers, convert the signed
> numbers to unsigned numbers and adjust the result's sign accordingly.)

How would the conversion from signed to unsigned be done without a modulus
function?  For example -11 = -2 = 7 (mod 9) but am I supposed to repeatedly
add 9 to my negative number until it becomes positive?  I thought that was
the whole point of having a modulus function.  What if I ask what is -12323
mod 9?  I can always make a conversion like this:

-12323 - (9 * (floor(-12323/9))

But then I'm implementing a mod function myself.

Presumably this is the same in C++ which shares C's standard numerical
library IIRC. 


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux