floattov16
Posted: Mon Jun 25, 2012 7:08 pm
Consider this code:
floattov16 converts incr and decr saturating the results, but value and 8.0f are converted as 0x00007FFF. I'm a little bit confused, is this the expected behavior?
Code: Select all
#include <nds.h>
#include <stdio.h>
volatile float incr = 0.0f;
volatile float decr = 0.0f;
volatile float value = 8.0f;
//---------------------------------------------------------------------------------
void Vblank() {
//---------------------------------------------------------------------------------
incr += 0.1f;
decr -= 0.1f;
}
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
irqSet(IRQ_VBLANK, Vblank);
consoleDemoInit();
while(1) {
swiWaitForVBlank();
printf("\x1b[6;0HIncr = %f",incr);
iprintf("\x1b[7;0HIncr = %08X",floattov16(incr));
printf("\x1b[10;0HDecr = %f",decr);
iprintf("\x1b[11;0HDecr = %08X",floattov16(decr));
iprintf("\x1b[13;0HAbsolute = %08X",floattov16(8.0f));
iprintf("\x1b[14;0Hvalue = %08X",floattov16(value));
}
return 0;
}