# Changes

,  00:20, 24 March 2009
Output for lua code
<context source="yes">
\dimen0=15pt
\dimen1dimen2=20pt
\number\dimexpr\dimen0/\dimen2\relax
</context>
{{todo|Fix me!}}
''The result of the integer division is 1 (rather than the decimal 0.75); This illustrates that the result of dividing two numbers that are nearly equal within TeX is not very useful. We can get around this by multiplying the numerators by some large factor, assuring that the evaluated fractions remain integer:''
== LuaTeX ==
''Alternatively, we can use luaTeX to reliably get the correct result. The <code>\type{tex.dimen}</code> command allows us to access the <code>\dimen</code> register from TeX in Lua.''
<context source="yes"texcode>
\dimen0=15pt
\dimen2=20pt
end
\stopluacode
</texcode>

<context>
\dimen0=15pt
\dimen2=20pt
\dimen4=15pt
\dimen6=30pt

\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax
The second fraction is now greater.
\else
The first fraction is still greater.
\fi
</context>
{{todo|I guess that the online conTeXt doesn't do luacode...}}
''and''
<context source="yes"texcode>
\dimen0=15pt
\dimen2=20pt
end
\stopluacode
</texcode>

<context>
\dimen0=15pt
\dimen2=20pt
\dimen4=15pt
\dimen6=15pt

\ifdim\dimexpr100\dimen0/\dimen2\relax<\dimexpr100\dimen4/\dimen6\relax
The second fraction is now greater.
\else
The first fraction is still greater.
\fi
</context>
''The output is now correct in both cases without making use of any tricks.''
gardener
110

edits