Hi.

I'm using Falch.net.

Could anyone tell me what is the exactly error for the following:

" The program just executed an illegal/unknown machine language instruction.
The opcode executed was 0x414D".

The error come out when it reach the function DoubleToString :    (error
until ->*d = *d * 10 + (*str - '0');)

Boolean StringToDouble(Char *str, double *d)
{
/* Whether or not the number is negative */
Boolean negative = (*str == '-');
/* Skip the minus sign if the number is negative */
if(negative)
str++;

/* It is an error if the string is empty or just "-" */
if(*str == 0)
return true; /* error */

/* Convert the digits to the left of the decimal sign */
*d = 0;
while(*str != '.' && *str != 0)
{
if(*str < '0' || *str > '9')
    return true; /* error */

*d = *d * 10 + (*str - '0');    ==> Error on this line
str++;
}
/* Convert the digits to the right of the decimal sign (if any) */
if(*str == '.')
{
double fraction = 0;

Char *end = ++str;
while(*end != 0) {
if(*end < '0' || *end > '9')
return true; /* error */
end++;
}
/* Now end points to the end of the string (the final 0 character).
* Backtrack and calculate the fraction part of the number.
*/
while(end > str)
fraction = (fraction+(*(--end) - '0'))/10;
/* Add the fraction part of the number */
*d += fraction;
}

/* Apply the correct sign */
if(negative)
*d = - *d;
/* Everything's OK */
return false;
}

FYI, the DoubleToString function is copied from someone's code and I have
made use of it for other program and it works fine. I didn't change any code
for the function and my String passed is '0' (but even '1' also cannot). Pls
advise.



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to