FloatToStr(f:n:n) problem

  • 1
  • 2
  • Page 1 of 2
allan
Benutzer
Avatar
Gender: n/a
Age: 64
Posts: 11
Registered: 10 / 2016
Subject:

FloatToStr(f:n:n) problem

 · 
Posted: 04.10.2017 - 16:50  ·  #1
Hi,
With new compiler (5.09.18) any attempt to convert float to string causes crash!
This does not work any more, even in simulator:

Float1 := 0.1001;
Float2 := 2.0002;
st := FloatToStr(Float1:6:4) + ' ' + FloatToStr(Float2:6:4);
Gunter
Administrator
Avatar
Gender:
Location: Frankfurt Main / Germany
Posts: 1697
Registered: 02 / 2003
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 04.10.2017 - 23:20  ·  #2
allan
Benutzer
Avatar
Gender: n/a
Age: 64
Posts: 11
Registered: 10 / 2016
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 05.10.2017 - 13:04  ·  #3
OK, understood, but this is so easy to reproduce, just copy-paste these 3 lines and try.
Something bad happened to floating point numbers while I did not update (since 2012).

Code

program avrprommer;

{$NOSHADOW}

{ $W+ Warnings}            {Warnings off}

Device = mega64, VCC=3.3;

Import SysTick, WatchDog;

From System Import  Float;

Define
        ProcClock   = 6000000;

        SysTick     = 10;            {msec}
        StackSize   = $0040, iData;
        FrameSize   = $0040, iData;
        
        WatchDog       = msec2000;



Implementation


{$IDATA}
{--------------------------------------------------------------}
{ Type Declarations }

type

{--------------------------------------------------------------}
{ Const Declarations }


{$EEPROM}
{--------------------------------------------------------------}

Structconst



{--------------------------------------------------------------}
{ Var Declarations }
{$IDATA}

Var

        st             : string[16];
        Float1, Float2 : float;

const


{--------------------------------------------------------------}
{ functions }




{ Main Program }
{$IDATA}

begin

  // ----- DEBUG  ----
  Float1 := 0.1001;
  Float2 := 2.0002;
  st := FloatToStr(Float1:6:4)  + '  ' + FloatToStr(Float2:6:4);

  
end avrprommer.

Gunter
Administrator
Avatar
Gender:
Location: Frankfurt Main / Germany
Posts: 1697
Registered: 02 / 2003
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 05.10.2017 - 14:33  ·  #4
Hi.

I found no problem with 5.09.18

Gunter
Attachments
FloatToStr(f:n:n) problem
Filename: 2017-10-05_143002.png
Filesize: 15.82 KB
Title:
Download counter: 136
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 05.10.2017 - 15:18  ·  #5
Allan, Gunter,

I also checked this example

rolf
Attachments
FloatToStr(f:n:n) problem
Filename: Float.jpg
Filesize: 14.84 KB
Title:
Download counter: 129
allan
Benutzer
Avatar
Gender: n/a
Age: 64
Posts: 11
Registered: 10 / 2016
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 05.10.2017 - 17:37  ·  #6
I see - if you just 'Make' it works, but 'Make & Optimize' was what I did...
So it must be optimizer related problem.
Gunter
Administrator
Avatar
Gender:
Location: Frankfurt Main / Germany
Posts: 1697
Registered: 02 / 2003
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 05.10.2017 - 17:53  ·  #7
yes you are right !
Optimize creates an endless loop.

Merlin ?

Edit:
the problem is the optimisation of the FloatToStr function !
even "st := FloatToStr (1);" creates a loop.
Attachments
Filename: ASM-DSM.zip
Filesize: 16.34 KB
Title:
Download counter: 33
rh
Administrator
Avatar
Gender:
Location: Germany
Age: 24
Homepage: e-lab.de
Posts: 5558
Registered: 03 / 2002
Subject:

Re: FloatToStr(f:n:n) problem

 · 
Posted: 05.10.2017 - 18:56  ·  #8
Hello Allan,

without complete environment and other infos we can't
evaluate such problems.
As always:
doesn't work ... doesn't help

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: 18 · Cache Hits: 15   145   160 · Page-Gen-Time: 0.045514s · Memory Usage: 2 MB · GZIP: on · Viewport: SMXL-HiDPI