Hello.

you can�t use StrAtoI because "1.05" is a real no integer...., you can
use "strToDouble"

Espero que te sirva de ayuda ...
Adios!!!

ej.

/**********************************************/
double numero;
char cadena[15];

StrPrintF (cadena,"%s","1.05");

numero = strToDouble(cadena);

/*************************************************
pass str TO double
******************/

double strToDouble(char *str)
{ Int i,start,length,punctPos;
  double result,sign,fractPart;

  result=fractPart=0.0;
  length=punctPos=StrLen(str);



  start=0;
  sign=1.0;
  if (str[0]=='-'){
     sign=-1.0;
     start=1;
    }

   for (i=start;i<length ;i++){
     if (str[i]!='.')
     { if ((str[i]=='0')||(str[i]=='1')||(str[i]=='2')||(str[i]=='3')   
||(str[i]=='4')||(str[i]=='5')||(str[i]=='6')||
(str[i]=='7')||(str[i]=='8')||(str[i]=='9') )

          result=result * 10.0+(str[i] - 0x30);
          else { return 0.0;
                }
        }
        else { punctPos=i;
               break;}
       }
     if (str[punctPos]=='.')
        {for(i=length-1;i>punctPos;i--)
           {if 
((str[i]=='0')||(str[i]=='1')||(str[i]=='2')||(str[i]=='3')||(str[i]=='4')||(str[i]=='5')||(str[i]=='6')||(str[i]=='7')||(str[i]=='8')||(str[i]=='9')
 
)
                fractPart = fractPart/10.0 + (str[i] - 0x30);
               else {return 0.0;
                     }
             }
            result +=fractPart / 10.0;
            }
            return result*sign;
     }
                                                                             
                                                                             
                                                                             
                                                           //******
pass double to Str with  n decimal digits                                    
                                ****/
void doubleToStr (char *str,double flpNumber,Int numFractDigits)
{
  Long longNumber;
  double flpIP,zeros,round;
  Int i,remainder,strLen;
  char sign=' ';

  if (flpNumber<0.0)
  { flpNumber=-flpNumber;
    sign='-'; }

   zeros =1.0;
   for (i=0;i<numFractDigits;i++)
   zeros*=10;

   round=0.5/zeros;
   flpNumber +=round;
   flpIP=(long) flpNumber;
   flpNumber = flpNumber - flpIP;
   str[0]=sign;

   if (sign=='-')
      StrIToA(&str[1],(long) flpIP);
    else
      StrIToA(&str[0],(long) flpIP);

   strLen=StrLen(str);
   str[strLen]='.';
   str[numFractDigits + strLen + 1] ='\0';
   longNumber = flpNumber * zeros;
   for (i=numFractDigits + strLen;i>strLen; i--)
   {remainder = longNumber %10;
    str[i]=remainder + 0x30;
    longNumber /=10;
    }

  }




>From: Johnathan Smith <[EMAIL PROTECTED]>
>Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>Subject: Need help calcing float(double)
>Date: Tue, 22 Jan 2002 07:20:22 -0800 (PST)
>
>I have a sting in a database which has numbers like
>
>"0.5","1.5" etc
>
>I cant use StrAToI to get the number!  Can someone
>please tell me what funcation I should use and also
>which type I should save it to!
>
>
>Thanks
>
>
>__________________________________________________
>Do You Yahoo!?
>Send FREE video emails in Yahoo! Mail!
>http://promo.yahoo.com/videomail/
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe, 
>please see http://www.palmos.com/dev/tech/support/forums/


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx


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

Reply via email to