gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > float problems

#97894 - koryspansel - Sat Aug 12, 2006 5:28 am

Is there a reason this doesn't work?:

Code:

float a = 100.0f
float b = 50.0f;

if(a > b)
{
    b = a;
}


But this works:

Code:

float a = 100.0f;
float b = 50.0f;

if((int32)a > (int32)b)
{
    b = a;
}


b should be set to 100.0f in both cases, but the float compare doesn't seem to work for me. Can anyone shed some light? thanks.

--
Kory

#97930 - dj-ceejay - Sat Aug 12, 2006 11:49 am

Doesn't DS use fixed point not floating point - even though the variable is called 'float'. Have a look in the libnds headers to see what it is defined as.
_________________
Fruit Machine Games:
http://www.fmsoftware.info/

#98063 - koryspansel - Sat Aug 12, 2006 11:29 pm

Well, float is an intrisic type, what kind of ARM asm gets generated by the compiler when used, I have no idea. And the nds headers do contain a float type:

Code:

typedef float float32;


But it's essentially the same thing I was using. In the end it doesn't matter anymore, I've converted everything to fixed-point. Thanks for the help though.

--
Kory

#98086 - silent_code - Sun Aug 13, 2006 4:01 am

well, the name of a type really doesn't matter.

in the end everything is a matter of interpreting memory. so if you tell your compiler a variable is a float, it takes care of how the momory is being processed and interpreted. no matter what's the best type for use with the current hardware. sure, there are some limitations, but the nds is rather powerfull and is able to handle floats, though it's not the recommended type to use (definitely slower than fixed point math).

... all in all floats work fine for me. don't know why your code doesn't work. (?) :|

#98101 - knight0fdragon - Sun Aug 13, 2006 6:05 am

hmm perhaps this was a typo when pasting your code to the board, but the first part is missing a semicolon
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206