On 2/9/2026 12:56 PM, Jean-Pierre Delange via ntg-context wrote:
Hi Michael,
It seems (AMHA) that this is not a bug but a difference between
formatting and calculation. The format specifier |@ "0.2f €"|only
affects how the value is /displayed/; it does not round the underlying
numeric result. Internally, |sum(D) * 0.21|is still computed with full
precision, and that unrounded value is then used in the total. If the
VAT must be rounded according to accounting rules before it contributes
to the final sum, the rounding has to be done explicitly in the
expression, for example:
|@ "0.2f €" round(sum(D) * 0.21, 2)|
This way the VAT is numerically rounded to two decimals, and the total
will come out as expected.
actually %f does round
\startluacode
local v = 1.5460003
context("%0.2f",v)
context.par()
context("%0.5f",v)
context.par()
context("%2r",v)
context.par()
context("%.5N",v)
\stopluacode
-----------------------------------------------------------------
Hans Hagen | PRAGMA ADE
Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the
Wiki!
maillist : [email protected] /
https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________