On 12/25/2011 10:57 PM, Don wrote:
On 24.12.2011 22:12, bearophile wrote:
Caligo:
I'm hoping to see something like the above mod function in Phobos someday.
I'd like that, for both int/long/BigInts. And I'd like some functions for
BigInts:
- divmod: returns both % and div and %, but it's mor
On 24.12.2011 22:12, bearophile wrote:
Caligo:
I'm hoping to see something like the above mod function in Phobos someday.
I'd like that, for both int/long/BigInts. And I'd like some functions for
BigInts:
- divmod: returns both % and div and %, but it's more efficient if you need
both value
Caligo:
> I'm hoping to see something like the above mod function in Phobos someday.
I'd like that, for both int/long/BigInts. And I'd like some functions for
BigInts:
- divmod: returns both % and div and %, but it's more efficient if you need
both values;
- gcd
- pow: with a third optional arg
On 21/12/2011 06:08, Caligo wrote:
assert(mod(-6, 20) == 14);
assert(mod( 6, -20) == -14);
assert(mod(-6, -20) == -6);
I'm hoping to see something like the above mod function in Phobos someday. And
perhapse a
'rem' or 'remainder' function that's a wrapper for the % operator, just t
On 21.12.2011 07:08, Caligo wrote:
1.
The % operator, just like in C/C++, calculates the remainder, but it
doesn't handle negative numbers properly. It's not a mod operator, even
though sometimes it's called that.
assert(-6 % 20 == -6);
assert( 6 % -20 == 6);
assert(-6 % -20 == -6);
1.
The % operator, just like in C/C++, calculates the remainder, but it
doesn't handle negative numbers properly. It's not a mod operator, even
though sometimes it's called that.
assert(-6 % 20 == -6);
assert( 6 % -20 == 6);
assert(-6 % -20 == -6);
I use my own mod function whenever I ne