Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2014-12

Real number display

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Chris Kelling
RealNumber := 1.5;
FloatToStr(RealNumber:2,RealStr);
DbeditBox.text := RealStr

The ":2" specifies the number of decimal. If you were using WRITE to output to the console, it would look like:

RealNumber := 13.3456;
writeln('Number = ',RealNumber:3:2);

Which would output
Number = 13.34

The first number = the number of spaces after the literal (notice the extra space after the equals), and the second is the number of decimal places to print. NOTE, in both examples, the formatting dies bit change the value (i.e. No rounding or trunking happen, just the number of decimal places specified are printed).

Hope that helps.

-Chris
-------- Everything at or below the line is a signature, not to be confused with the body of the email above. Sorry about the last signature text that seemed to have some people questioning my sanity.

We are what we repeatedly do. Excellence, then, is not an act, but a habit.

-Aristotle

Show quoted text 10 lines
On Dec 9, 2014, at 23:03, Larry Dalton wrote: How do I get a real number to display as a decimal in a dbedit instead of an exponential number? Sent from my iPhone -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20141209/db245e5c/attachment.html>

Reply by email

Larry Dalton
to Chris Kelling

Works great! Thanks!

Sent from my iPhone

Show quoted text 43 lines
On Dec 9, 2014, at 22:23, Chris Kelling wrote: RealNumber := 1.5; FloatToStr(RealNumber:2,RealStr); DbeditBox.text := RealStr The ":2" specifies the number of decimal. If you were using WRITE to output to the console, it would look like: RealNumber := 13.3456; writeln('Number = ',RealNumber:3:2); Which would output Number = 13.34 The first number = the number of spaces after the literal (notice the extra space after the equals), and the second is the number of decimal places to print. NOTE, in both examples, the formatting dies bit change the value (i.e. No rounding or trunking happen, just the number of decimal places specified are printed). Hope that helps. -Chris -------- Everything at or below the line is a signature, not to be confused with the body of the email above. Sorry about the last signature text that seemed to have some people questioning my sanity. We are what we repeatedly do. Excellence, then, is not an act, but a habit. -Aristotle > On Dec 9, 2014, at 23:03, Larry Dalton wrote: > > How do I get a real number to display as a decimal in a dbedit instead of an exponential number? > > Sent from my iPhone > -- > _______________________________________________ > Lazarus mailing list > > http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20141209/85832a08/attachment-0001.html>

Reply by email