[Icc-avr] sprintf limitation?

Svenn Dahlstrøm svenn at sleipner.no
Thu Jul 3 23:42:56 PDT 2008


Hi Paul

Try to declare max_flow as an unsigned long or max_flow = (double)temp;

Svenn :)

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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20080704/db6c91ce/attachment.html


More information about the Icc-avr mailing list