StrToFloat bug report

  • 1
  • 2
  • Page 1 of 2
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

StrToFloat bug report

 · 
Posted: 30.03.2015 - 15:59  ·  #1
Conversion from string to float seams to error in exponent calculation. Problem exists with and without simulator.

Code
var
  f: float;
  s: string[50];
...
    s := '      12345678.9'; // x1
    f := StrToFloat(s);
    s := s + ' = ' + FloatToStr(f) + '   ';
    WriteLn(LCDout, s);      // '12345678.9 = 1.234568E7' (good)

    s := '    1234567890.0'; // x100
    f := StrToFloat(s);
    s := s + ' = ' + FloatToStr(f) + '   ';
    WriteLn(LCDout, s);      // '1234567890.0 = 1.234568E8' (<<< bad, E8 should be E9 !!!)

    s := '12345678900000.0'; // x1.000.000
    f := StrToFloat(s);
    s := s + ' = ' + FloatToStr(f) + '   ';
    WriteLn(LCDout, s);      // '12345678900000.0 = 1.272353E12' ((<<< bad, E12 should be E13 !!!)
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: StrToFloat bug report

 · 
Posted: 07.04.2015 - 14:29  ·  #2
Hello Avra,

I tried to find the bug. But the driver is completely written in ASM and
I could not locate the problem. I'm somewhat baffled. Sorry.

rolf
Harald_K
 
Avatar
 
Subject:

Re: StrToFloat bug report

 · 
Posted: 07.04.2015 - 18:27  ·  #3
just tested with my 3.98 compiler build ....

same problem .... and the first value is converted to 12345678 without exponent
(all only in simulator)

just a remark: the mantissa of the third value in avra's post looks a little bit mixed-up - maybe a problem with frame size or so?
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: StrToFloat bug report

 · 
Posted: 07.04.2015 - 19:07  ·  #4
Hello Harald,
sorry. I really don't know what is going on there.
It is many, many years ago and all written in ASM. :aerger:
rolf
Harald_K
 
Avatar
 
Subject:

Re: StrToFloat bug report

 · 
Posted: 07.04.2015 - 22:52  ·  #5
so ... little bit of ASM-practice helps sometimes ...

this problem occurs only if you use large numbers (more than 8 digits) in non-scientific notation.
lets say 123456.7e13 works good, 12345670000000 doesnt work.

i fear, the same type of error will occure if you convert very small numbers in non-scientific, e.g. 1e-15 will work, 0.000000000000001 might not

i dont know if this is a real "error", because
transferring large strings on a microcontroller with restricted size of RAM is no good idea - stack and frame will catch more space than available, especially when you use some recursive calls.

@rolf:
maybe, one additional inc _accahi at the end of the Str2Flt4-code directly before the str2flt6 entrypoint will fix the problem .... but do some checkout with different sizes of stringnumbers and decimalpoint positions ... i'm still analyzing
Avra
Schreiberling
Avatar
Gender:
Location: Belgrade, Serbia
Age: 53
Homepage: rs.linkedin.com/in…
Posts: 653
Registered: 07 / 2002
Subject:

Re: StrToFloat bug report

 · 
Posted: 09.04.2015 - 20:16  ·  #6
Quote by rh

I tried to find the bug. But the driver is completely written in ASM and
I could not locate the problem. I'm somewhat baffled. Sorry.


I will reimplement StrToFloat when I catch time...
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: StrToFloat bug report

 · 
Posted: 10.04.2015 - 14:13  ·  #7
Hello Avra,

a Pascal replacement of the StrToFloat function doesn't help.
The bug must be removed in our code generator (ASM) in the
AVRco. User Harald_K already tries to find the bug.

rolf
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: StrToFloat bug report

 · 
Posted: 11.04.2015 - 20:16  ·  #8
@Avra,
StrToFloat bug is fixed now.

rolf
  • 1
  • 2
  • Page 1 of 2
Selected quotes for multi-quoting:   0

Registered users in this topic

Currently no registered users in this section

The statistic shows who was online during the last 5 minutes. Updated every 90 seconds.
MySQL Queries: 15 · Cache Hits: 14   131   145 · Page-Gen-Time: 0.028973s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI