![]() |
Calculating error
I've been learning pascal recently and i cant seem to do simple calculations correctly.
Example: :
program calculate;Returns a value of 1.800000000Ex01 Any ideas? Thanks in advance. |
Depending on the input of course there is probably nothing wrong with that output, which has a value of 18 I believe.
I guess where you're having difficulty is in the representation of reals when printed, in this case in exponential or scientific format. Unfortunatly I don't know pascal to suggest a way of changing the output but I'm sure someone here will :) . |
Yea found the problem.
Needed to show how many digits:decimal places i wanted to display: :
Writeln('Total cost: ', people*cost:6:2);Thanks anyway Eoin :) |
| All times are GMT -5. The time now is 1:02 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC