Hi all!
i'm just messing around with math operations.while dealing with miles to kilometers conversion and
after setting setprecision to 10 digits , i received a "weird" result.
I mean, see the code below, the result i expected was : 1.6093440000
Any idea on the reasons why i get 1.6093440056 instead ?
/* miles to kilometers */
/* Thursday Oct 4th 2007 */
/* pistol350 */
REM compile as console window
' 1 mile = 1,609344 kilometers
'CONST fConv = 1.609344
/******************************************/
SETPRECISION 10
$OPTION "FLOAT"
REM These will all be defined as type FLOAT
fConv = 1.609344
fOutput = 0
fResults = 0
/******************************************/
OPENCONSOLE
input "enter miles value to receive the output in kilometers: ",fOutput
fResults = (fOutput*fConv)
print "results in kilometers : ",fResults
print "press a key to quit"
do:until INKEY$<>""
closeconsole
END
here's how i do it in one of my program ;)
/* miles to kilometers */
/* Thursday Oct 4th 2007 */
/* krypt :D */
REM compile as console window
/******************************************/
float fOutput
float fResults
/******************************************/
OPENCONSOLE
input "enter miles value to receive the output in kilometers: ",fOutput
fResults = (fOutput / 0.6214);
print "results in kilometers : ",USING("%f#.# KM",fResults)
print "press a key to quit"
do:until INKEY$<>""
closeconsole
END
but i dont know how to do that your way ???
just add # in USING for more precision ;)
Tut, tut Mr Pistol .. :) haven't you read any of my notes on variable precision ..
Using 'Float' variables you can only rely on 7 significant figures. If you need more, you have to use type 'Double' .. :)
all the best,
Graham
Lol! ;D
Thank you Krypt for the working example and the tips.
I Thank you as well Graham for hitting me with a rod ::)
LOL
we sometimes need to be taught with the old school ways to be a hardworking student ;)
PS: There is a ";" in line 11 Into Krypt's code that should not be there.
Aurora,Aurora,Aurora..... ;D
Just a note ;)
He .. He .. :)
Graham
yep your right :D
but does nothing bad ... didnt even notice ..hehe