StrToFloat bug report

  • 1
  • 2
  • Seite 1 von 2
Avra
Schreiberling
Avatar
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

StrToFloat bug report

 · 
Gepostet: 30.03.2015 - 15:59 Uhr  ·  #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
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: StrToFloat bug report

 · 
Gepostet: 07.04.2015 - 14:29 Uhr  ·  #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
 
Betreff:

Re: StrToFloat bug report

 · 
Gepostet: 07.04.2015 - 18:27 Uhr  ·  #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
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: StrToFloat bug report

 · 
Gepostet: 07.04.2015 - 19:07 Uhr  ·  #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
 
Betreff:

Re: StrToFloat bug report

 · 
Gepostet: 07.04.2015 - 22:52 Uhr  ·  #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
Geschlecht:
Herkunft: Belgrade, Serbia
Alter: 54
Homepage: rs.linkedin.com/in…
Beiträge: 653
Dabei seit: 07 / 2002
Betreff:

Re: StrToFloat bug report

 · 
Gepostet: 09.04.2015 - 20:16 Uhr  ·  #6
Zitat geschrieben von 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
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: StrToFloat bug report

 · 
Gepostet: 10.04.2015 - 14:13 Uhr  ·  #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
Geschlecht:
Herkunft: Germany
Alter: 25
Homepage: e-lab.de
Beiträge: 5558
Dabei seit: 03 / 2002
Betreff:

Re: StrToFloat bug report

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

rolf
  • 1
  • 2
  • Seite 1 von 2
Gewählte Zitate für Mehrfachzitierung:   0

Registrierte in diesem Topic

Aktuell kein registrierter in diesem Bereich

Die Statistik zeigt, wer in den letzten 5 Minuten online war. Erneuerung alle 90 Sekunden.
MySQL Queries: 14 · Cache Hits: 14   131   145 · Page-Gen-Time: 0.036823s · Speichernutzung: 2 MB · GZIP: ein · Viewport: SMXL-HiDPI