Computer Science Canada Help with displaying real values |
Author: | MattyGG [ Tue Feb 07, 2006 2:50 pm ] |
Post subject: | Help with displaying real values |
I'm trying to display real values as dollar values, but if the user inputs a real value to under 2 decimal places, it will only output up to those two spaces...eg, the user inputs "6.5" it outputs "6.5" when i want it to output "6.50" |
Author: | Tony [ Tue Feb 07, 2006 3:04 pm ] | ||
Post subject: | |||
where :n will format to n decimal places. |
Author: | Delos [ Tue Feb 07, 2006 4:33 pm ] | ||||
Post subject: | |||||
Tony wrote:
where :n will format to n decimal places. Oh, so close Tony, so very close. The first colon : number complex refers to the number of spaces allocated to that output. For decimal places, you'll want the second colon : number. i.e.
|
Author: | Cervantes [ Tue Feb 07, 2006 4:43 pm ] | ||
Post subject: | |||
This can also be done using frealstr which is a type convertion from real to string, where f stands for fraction. frealstr (r : real, width, fractionWidth : int)
It's basically the same as what Delos has, there. The only difference is that this is a manual type convertion, and thus allows you to use it in Font.Draw or other such places where you need a string. |