On Sat, Jun 28, 2008 at 06:36:34PM +0200, Ivan Voras wrote: > Does anyone know of a simple, BSD (or compatible) licensed software > math library that emulates floating point numbers? Ideally, it should > be a single .c file library that implements basic operations (+, -, *, > /, negation, comparisons, convert to/from machine integers and > strings), that uses a standard C type (int or long long) to store the > value, and is usable in the kernel. > > Alternatively, how about a fixed-point library with the same > properties? (I know it's easy to do, but don't want to reinvent the > wheel again if I don't have to). >
If you don't mind having unlimited precision, check out the math library used in the calc program from isthe.com. USING THE ARBITRARY PRECISION ROUTINES IN A C PROGRAM Part of the calc release consists of an arbitrary precision math link library. This link library is used by the calc program to perform its own calculations. If you wish, you can ignore the calc program entirely and call the arbitrary precision math routines from your own C programs. The link library is called libcalc.a, and provides routines to handle arbitrary precision arithmetic with integers, rational numbers, or complex numbers. There are also many numeric functions such as factorial and gcd, along with some transcendental functions such as sin and exp. Take a look at the sample sub-directory. It contains a few simple examples of how to use libcalc.a that might be helpful to look at after you have read this file. _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "[EMAIL PROTECTED]"