mickey
4th February 2008, 14:40
Hello,
I'd like build my own math class library (without using cmath or other). I'm doing the division:
At the moment I'm doing operation between integer and every method ust return an integer; IDiv return the integer part if it cannot do the division; to do this I thought to exploit (int); see below:
int IDiv( int a, int b ) {
assert (b != 0);
return (int) ((float) a / (float) b);
}
Is it beautiful?
Willing avoid the C/C++ math library, now I'm wonder how to do the rest of a division.....
Suggests?
I'd like build my own math class library (without using cmath or other). I'm doing the division:
At the moment I'm doing operation between integer and every method ust return an integer; IDiv return the integer part if it cannot do the division; to do this I thought to exploit (int); see below:
int IDiv( int a, int b ) {
assert (b != 0);
return (int) ((float) a / (float) b);
}
Is it beautiful?
Willing avoid the C/C++ math library, now I'm wonder how to do the rest of a division.....
Suggests?