xboxscene.org forums

OG Xbox Forums => Software Forums => Development => Topic started by: Mios∞ft on May 09, 2008, 04:31:00 PM

Title: Datatype Float To Int/short Not Working?!
Post by: Mios∞ft on May 09, 2008, 04:31:00 PM
CODE
debugPrint("%g,%g\n",(((((float)(g_DefaultPad.sLThumbX+32767)/32767.0f)*100.0f)-100.0f)/100.0f)*255.0f,(((((float)(g_DefaultPad.sLThumbY+32767)/32767.0f)*100.0f)-100.0f)/100.0f)*255.0f);


Works,

However A VERY simple thing such as this show only extreme values  uhh.gif :

CODE
debugPrint("%d,%d\n",(int)(((((float)(g_DefaultPad.sLThumbX+32767)/32767.0f)*100.0f)-100.0f)/100.0f)*255.0f,(int)(((((float)(g_DefaultPad.sLThumbY+32767)/32767.0f)*100.0f)-100.0f)/100.0f)*255.0f);


Something wrong with FPU unit?
Title: Datatype Float To Int/short Not Working?!
Post by: Mios∞ft on May 10, 2008, 07:50:00 AM
CODE
sprintf("%.0f,%.0f",valx,valy);
 laugh.gif
Title: Datatype Float To Int/short Not Working?!
Post by: obcd on May 13, 2008, 03:25:00 AM
Hi,

(int) is not really converting the floats. It is just telling the compiler to interpret them as integers.
Since integers and floating point numbers are stored on a totally different way, it is normal you get a strange result.
Casting is more a way to override the parameter check of a function, so it should be used carefully.

regards.