Floating-point/fixed-point arithmetic

SGDK only sub forum

Moderator: Stef

Post Reply
Zontar
Very interested
Posts: 55
Joined: Fri Oct 21, 2011 8:58 pm

Floating-point/fixed-point arithmetic

Post by Zontar »

In coding my port of Ken Perlin's noise generator, I discovered there are no library functions for floating-point or fixed-point arithmetic (or my setup is configured incorrectly.) For example, the following reveals no __divdf3 implementation upon compilation:

Code: Select all

double divide(double x, double y) {
	return x / y;
}
With this in mind, what options do I have for decimal point arithmetic? I understand floating-point emulation is slow, however, this will be used for a map generator that runs once (with a waiting screen) so speed is not too much an issue. Is there a library I can use for real number arithmetic, either fixed-point or floating-point arithmetic?
Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef »

Indeed there is no support for float and double operation in SGDK as the 68000 is really not suited for floating point types.
You can still use the fix32 type (fixed point decimal) with SGDK if your decimal numbers are not too small nor too big.
Post Reply