Q2687 and floating point

I am using the Fastrack Supreme, it has the Q2687 CPU. I will like to know if it handles floating point calculations well and if
wm_sprintf handles float type well.

void print10minData(u8 TimerIdOne)
s8 val;
ascii RspBuffer[60];

/* Get the current position */
val = FillGPSData();

if (val < 0)
    adl_atSendResponsePort ( ADL_AT_RSP, ADL_PORT_UART1, "\r\nM2M Weather Station: GPS Fix not obtained yet\r\n");

/* Print the position on serial port */
/* Format==> Decimal degree */
wm_sprintf(RspBuffer, "\r\nLong/Lat/Alt: %0.02f%c, %0.02f%c, %0.02f%c\r\n",

/* Send the buffer on serial */
adl_atSendResponsePort ( ADL_AT_RSP, ADL_PORT_UART1, RspBuffer);


when i look at the results on UART1. the longitude and latitude always have 2 decimal points as expected but sometimes the altitude has about 7 decimal places. After some time it has 2 decimal places as expected. Altitude also varies a lot, Is it because of the floating issue or the GPS altitude measurements ?

Somtimes the altitude has the following value: 0.429496726m then after sometime it is ok. even then it is not fixed like the longitude and latitude. It varies a lot. I am using the sample CGPS program: “Simple Sample”

there is some warning in documentation(Basic_development_guide) saying:

Important remark about GCC compiler:
When using GCC compiler, due to internal standard C library
architecture, it is strongly not recommended to use the “%f” mode in
the wm_sprintf function in order to convert a float variable to a
string. This leads to an ARM exception (product reset).
A way around for this conversion is:
float MyFloat; // float to display
ascii MyString [ 100 ]; // destination string
s16 d,f;
d = (s16) MyFloat * 1000; // Decimal precision: 3 digits
f = ( MyFLoat * 1000 ) - d; // Decimal precision: 3 digits
wm_sprintf ( MyString, “%d.%03d”, (s16)MyFloat, f ); // Decimal
precision: 3 digits

i hope it helps.

Thanks a lot, it works perfectly now

Thanks for the workaround. Here’s an extended example, using double and a precision of 6 digits:

double decimal = 1234.56789;
ascii result[20];
s32 f = (s32)(((double)(decimal - (s32)decimal)) * 1000000);  // Calc fractional part
if(f < 0) f = f * (-1);  // Fractional part must be positive
sprintf(result, "%d.%06d", (s32)decimal, f);

How it works:

  1. (double)(decimal - (s32)decimal) => 1234,56789 - 1234 = 0,56789
  2. 0,56789 * 1000000 = 567890 = f (fractional part)


Isn’t it about time this bug was actually fixed??!