explicit cast building own math library
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:
Code:
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?
Re: explicit cast building own math library
First question: why do you want to avoid the C-math library? There is nothing wrong with it.
Second question: are you are looking for floating point math routines for non-FP CPUs? If yes, have a look at http://www.radiks.net/~rhuebner/mathlib.html.
Comment on the current code: do not use C-style casts.
Re: explicit cast building own math library
Quote:
Originally Posted by
Thomas
First question: why do you want to avoid the C-math library? There is nothing wrong with it.
to do exercise. If used math.h, what does remain to do?
Quote:
Originally Posted by
Thomas
Comment on the current code: do not use C-style casts.
And If I used a C compiler?
Re: explicit cast building own math library
Quote:
And If I used a C compiler?
Why do you ask rhetorical questions?
Re: explicit cast building own math library
Quote:
Originally Posted by
mickey
If used math.h, what does remain to do?
I can give you dozens of tasks if you have too much free time :)
Re: explicit cast building own math library
Quote:
Originally Posted by
wysota
I can give you dozens of tasks if you have too much free time :)
Good one! :p
Re: explicit cast building own math library
I have some work like Wysota; if you want to share!!!:)