Arithmetic evaluation: Difference between revisions

Content added Content deleted
m (→‎{{header|Sidef}}: minor code simplifications)
m (fraction accuracy)
Line 3,644: Line 3,644:


procedure get_token()
procedure get_token()
atom n
atom n, fraction
integer dec
integer dec
skipspaces()
skipspaces()
Line 3,656: Line 3,656:
end while
end while
if ch='.' then
if ch='.' then
dec = 10
dec = 1
fraction = 0
while 1 do
while 1 do
nxtch(0)
nxtch(0)
if ch<'0' or ch>'9' then exit end if
if ch<'0' or ch>'9' then exit end if
n += (ch-'0')/dec
fraction = fraction*10 + ch-'0'
dec *= 10
dec *= 10
end while
end while
n += fraction/dec
end if
end if
-- if find(ch,"eE") then -- you get the idea
-- if find(ch,"eE") then -- you get the idea