Floating point to string conversion

Post your requests and ideas on the future development of mikroPascal for dsPIC30/33 and PIC24.
Post Reply
Author
Message
OT
Posts: 581
Joined: 19 May 2005 05:08
Location: Fairbanks, Alaska

Floating point to string conversion

#1 Post by OT » 20 May 2005 09:01

TP/BP/Delphi . has very simple formatting to output floating point numbers and integer numbers:

procedure Str(X [: Width [: Decimals ]]; var S:string);

Code: Select all

Flt      : Real;
I        : Integer;
St1,St2  : String;

Begin
   Flt:=4.2345;
   I:= 6;
   Str(Flt:5:2,St1);   {will output ‘ 4.23’}
   Str(I:4,St2);         {will output ‘   6’}
   Str(Flt:1:2,St1);   {will output ‘4.23’}
End;
If the number takes more spaces than allocated by Width the string will expand. This way it is possible to create both left and right justified strings.
Of course there are similar expressions with the Write and Writeln procedures, however with the large number of different displays this seems difficult to carry out (unless a system for a universal text output is created).
Conversion of floating point to a string would go a long way. There are of course numbers that require exponentials; however this should cover the most important cases. :roll: ME has not seemed to be willing to provide string formatting for floating point numbers in the PIC versions yet, :evil: however with the increased capacity of dsPIC, should not this be viable? :?: :idea:

Wished for the next release (not necessarily in exact same syntax, for instance a function would have been more convenient). :!:

User avatar
zristic
mikroElektronika team
Posts: 6608
Joined: 03 Aug 2004 12:59
Contact:

Re: Floating point to string conversion

#2 Post by zristic » 20 May 2005 09:26

We will consider it for both PIC and dsPIC.

Post Reply

Return to “mikroPascal for dsPIC30/33 and PIC24 Wish List”