Type real formatting

Post your requests and ideas on the future development of mikroPascal.
Post Reply
Author
Message
LGR
Posts: 3204
Joined: 23 Sep 2004 20:07

Type real formatting

#1 Post by LGR » 24 May 2005 17:41

I'm happy to see the addition of type real. The problem that I have is in formatting real variables into strings for output. As a minimum, there should be a function trunc() which returns the integer portion of the real number. With this, the fractional part can be caculated. :)

What would be better is to have functions trunc(), frac(), and round(). What would be even better than this, is function real_to_string(). The ultimate would be function real_to_string(), which allows the user to specify places before and after the decimal:

Code: Select all

Const A : byte = 4;
B : byte = 2;
Var C : real; Str : String[10];
Begin
C := 234.32587;
Str := Real_to_string(A,B,C);
Results in str = '234.33' 8)

Conversion the other way would also be nice.
If you know what you're doing, you're not learning anything.

Post Reply

Return to “mikroPascal Wish List”