Discussion:
Real variables question
(too old to reply)
Hernan Lara
2006-10-25 01:08:39 UTC
Permalink
Hi, im new to pascal, i have used it for about 2 weeks in school. Im having
a problem dealing with "real' numeric variables. Everytime i run my program
and write the value of a "real" variable i get it in exponent format; is
there any way to get over this and write the numbers without the exponent?
Thanks
David Pratt
2006-10-25 01:33:46 UTC
Permalink
Write (V1:minimun width:Decimal places);
So if you want to print a variable in a space 10 cahrs wide to two decimal
places, you would use:
Write(V1:10:2);

This also works with writeln.
Post by Hernan Lara
Hi, im new to pascal, i have used it for about 2 weeks in school. Im
having a problem dealing with "real' numeric variables. Everytime i run
my program and write the value of a "real" variable i get it in exponent
format; is there any way to get over this and write the numbers without
the exponent?
Thanks
Markus Humm
2006-10-25 19:25:53 UTC
Permalink
Hello,

another thing to consider is to use the data types extended or single
instead, as they can use the FPU and are standard where real is a
Borland construct.

Using the other "real" types requires this as the first line in your
program:

{$N+,E+}

This enables FPU usage and emulation.

Greetings

Markus
Dr J R Stockton
2006-10-26 15:59:18 UTC
Permalink
Post by Markus Humm
another thing to consider is to use the data types extended or single
instead, as they can use the FPU and are standard where real is a
Borland construct.
Using the other "real" types requires this as the first line in your
{$N+,E+}
This enables FPU usage and emulation.
That first line is NOT *required*; one can also do it by settings in one
of the IDE menus or by options for the command-line compiler.
--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 MIME.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/&c., FAQqy topics & links;
<URL:http://www.merlyn.demon.co.uk/clpb-faq.txt> RAH Prins : c.l.p.b mFAQ;
<URL:ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip> Timo Salmi's Turbo Pascal FAQ.
Markus Humm
2006-10-26 18:35:58 UTC
Permalink
[snip]
Post by Dr J R Stockton
That first line is NOT *required*; one can also do it by settings in one
of the IDE menus or by options for the command-line compiler.
Yes one can, but if you share the code with another person who doesn't
have these settings and doesn't even know about them you won't make
friends will you? ;-)

Greetings

Markus

Loading...