[Icc-avr] sprintf limitation?

John Baraclough j_baraclough at zetnet.co.uk
Fri Jul 4 03:33:52 PDT 2008


For that number range I don't understand why you think that need to use 
'double'. Just use 'long' and the 'atol(char *s)' function for conversion.

John

Svenn Dahlstrøm wrote:
>
> Hi Paul
>
>  
>
> Try to declare max_flow as an unsigned long or max_flow = (double)temp;
>
>  
>
> Svenn J
>
>  
>
> *Fra:* icc-avr-bounces at imagecraft.com 
> [mailto:icc-avr-bounces at imagecraft.com] *På vegne av* Paul Mateer
> *Sendt:* 3. juli 2008 16:25
> *Til:* Discussion list for ICCAVR and ICCtiny Users. You do NOT need 
> to subscribe to icc-announce if you are a member of this.
> *Emne:* [Icc-avr] sprintf limitation?
>
>  
>
> I'm running into a strange problem.  Trying to adjust my var. 
> "max_flow" from 0-99999.  This sort of works....but only up to 
> 39999!!!  Anything 40000 and above it returns me an "atof error - 
> number to big" .  Why?  According to STDLIB.H max is 2147483520.  Ideas???
>
> //-----------------------------------------------------------------------
>    double max_flow;
>    unsigned long temp;
>    char VAL[15];  
>   
>    max_flow = 39999; 
>
>    temp = (unsigned long)max_flow;
>    csprintf(VAL,"%05ld",temp);
>
>    dspsingle(0, 'M');
>    dspsingle(1, 'X');
>    dspsingle(2, '=');
>    dspsingle(3, VAL[0]);
>    dspsingle(4, VAL[1]);
>    dspsingle(5, VAL[2]);
>    dspsingle(6, VAL[3]);
>    dspsingle(7, VAL[4]);
>
>    VAL[0]= (adj_digit((VAL[0]-48), 3)) + 48;
>    wait_key();
>    VAL[1]= (adj_digit((VAL[1]-48), 4)) + 48;
>    wait_key();
>    VAL[2]= (adj_digit((VAL[2]-48), 5)) + 48;
>    wait_key();
>    VAL[3]= (adj_digit((VAL[3]-48), 6)) + 48;
>    wait_key();
>    VAL[4]= (adj_digit((VAL[4]-48), 7)) + 48;
>
>    a = (VAL[0] - 48) * 10000;
>    b = (VAL[1] - 48) * 1000;
>    c = (VAL[2] - 48) * 100;
>    d = (VAL[3] - 48) * 10;
>    e = (VAL[4] - 48);
>              
>    temp = a+b+c+d+e;
>    max_flow = temp;
> //----------------------------------------------------------------------------------------
>
> -- 
> Paul Mateer, AA9GG
> Elan Engineering Corp.
> www.elanengr.com <http://www.elanengr.com>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Icc-avr mailing list
> Icc-avr at imagecraft.com
> http://dragonsgate.net/mailman/listinfo/icc-avr
>   



More information about the Icc-avr mailing list