简体   繁体   中英

How to make data type “real” shorter in Pascal

My program transfers millimeters to meters and centimeters. And it is working, but answer is like 1,394900000000000000... How to make it shorter?

Program radiuss;
var 

mill : real;
metr : real;
cent : real;

Begin
Writeln('Сколько миллиметов надо перевести?');
Readln(mill);

metr := mill * 0.001;
cent := mill * 0.1;

Writeln('Метры:', metr);
Writeln('Сантиметры:', cent);

End.

You may specify how many digits of fraction part do you want to print in the writeln s. Here is example of how to print 3 and 1 digits respectively:

Writeln('Метры:', metr:0:3);
Writeln('Сантиметры:', cent:0:1);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM