nl
<mailto:ntg-context@ntg.nl>>
*Objet :*[NTG-context] Problem with string.format (Lua)
Hello,
I start with Lua and I try to display my result with 4 decimal
places without success.
Thank you
Fabrice
\startluacode
function Bino
reur <mailto:fabrice1.couvr...@gmail.com>
>> *Envoyé le :*dimanche 14 janvier 2018 13:05
>> *À : *mailing list for ConTeXt users <mailto:ntg-context@ntg.nl>
>> *Objet :*[NTG-context] Problem with string.format (Lua)
>>
>> Hello,
>> I start with Lua a
:05
*À : *mailing list for ConTeXt users <mailto:ntg-context@ntg.nl>
*Objet :*[NTG-context] Problem with string.format (Lua)
Hello,
I start with Lua and I try to display my result with 4 decimal places
without success.
Thank you
Fabrice
\startluacode
function Binomial(n,k,p)
if k >
Hi Fabrice,
string.format behaves more or less as C printf. You probably need to specify
%.4g in 1st argument.
Hope this helps
Best
Joseph
De : Fabrice Couvreur
Envoyé le :dimanche 14 janvier 2018 13:05
À : mailing list for ConTeXt users
Objet :[NTG-context] Problem with string.format (Lua
Hello,
I start with Lua and I try to display my result with 4 decimal places
without success.
Thank you
Fabrice
\startluacode
function Binomial(n,k,p)
if k > n then return nil end
if k > n/2 then k = n - k end
numer, denom = 1, 1
for i = 1, k do
numer = numer * ( n - i +