George
George

Reputation: 87

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.

Upvotes: 0

Views: 149

Answers (1)

Doj
Doj

Reputation: 1311

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

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

Upvotes: 2

Related Questions