Skip to content

Latest commit

 

History

History
43 lines (29 loc) · 1.05 KB

README.md

File metadata and controls

43 lines (29 loc) · 1.05 KB

Handlebars.java Math Helpers

Build Status

A Library of Helpers for performing simple math operations in Handlebars.

Perform math operations in handlebars. Inspired by this JSFiddle.

Operands are treated as java.math.BigDecimal and operations are performed with the java.math.MathContext.DECIMAL64 MathContext, yielding results with 16 bits of precision and rounding to the nearest even digit, according to IEEE 754R. You can force rounding decimal results using the extra parameter scale, which corresponds to calling BigDecimal.setScale(int scale, RoundingMode.HALF_UP).

addition

{{math arg0 "+" arg1}} // arg0 + arg1

subtraction

{{math arg0 "-" arg1}} // arg0 - arg1

multiplication

{{math arg0 "*" arg1}} // arg0 * arg1

division

{{math arg0 "/" arg1}} // arg0 / arg1

modulus

{{math arg0 "%" arg1}} // arg0 % arg1