[fpc-pascal] Cancelling Scientific notation
Frank Peelo
f26p at eircom.net
Mon Jan 25 19:53:27 CET 2010
On 25/01/2010 18:37, James Gibbens wrote:
> Hallo FPC gurus,
> I am VERY new to free pascal and I have a couple of problems. Can
> somebody please help?
> 1. If a, b are real numbers and I want to round a/b foo to 3 decimal
> places, the answer is displayed in Scientific notation. How do I turn
> that off?
Are you using Write and Writeln? For strings and integers, you can
specify the field width, e.g.
x := 'Hello';
Write(x:10);
will write the variable x using at least 10 characters, using spaces for
padding if necessary. For floating-point types you can also specify the
decimal places, e.g.
y := 12.345;
Writeln(y:0:2);
will write y using at least 0 characters, i.e. no padding at all, with 2
digits after the decimal point.
> 2. Without using Object Pascal, how can I change the background colour,
> a very black BLACK, when the program runs? It is strenuous on my poor eyes.
That I'm not so sure of. There used to be a crt unit, so add CRT to the
uses clause at the top of your program
uses foo, bar, CRT, whatever;
and then you could use
textbackground(blue);
textcolor(yellow);
and like that. I guess it's still supported.
Frank
More information about the fpc-pascal
mailing list