[ https://issues.apache.org/jira/browse/VELOCITY-242?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henning Schmiedehausen closed VELOCITY-242. ------------------------------------------- > [PATCH] Decimals in velocity > ---------------------------- > > Key: VELOCITY-242 > URL: https://issues.apache.org/jira/browse/VELOCITY-242 > Project: Velocity > Issue Type: Bug > Components: Engine > Affects Versions: 1.5 > Environment: Operating System: other > Platform: Other > Reporter: Peter Romianowski > Assigned To: Velocity-Dev List > Attachments: arithmetic.patch, arithmetic.patch, number-patch2.patch > > > Hi, > finally we got it together - the infamous "decimal number patch" evolved > and here is the (hopefully) final patch to enable decimal numbers (and > byte, short, long and BigInteger btw.) in velocity. This patch contains: > - Decimal literals (by Will Glass-Husain) > Now you can type things like #set ($foo = 3.14) > - All arithmetic operations (+ - / *) now work with all Number-types > available. Modulo (%) works with all except BigDecimal (there is no > such method :) > - All comparators (< > == != <= >=) work with all Number-types > - A new type called TemplateNumber (o.a.v.util.TemplateNumber) is > available which is treated as a Number in arithmetic operations and > comparisons. (by Will Glass-Husain) > I am not sure about this one though. But Will had good reasons to > implement it - I think I just need some kind of "refreshing" on that > ;) > The patch is against the current head (Geir, you gave me a hard time > during the last days, since you changed the Parser.jjt quite often, so > that I had to incorporate the changes quite some times ;) > Additionally some implementation details: > ----------------------------------------- > All aritmetic operations and comparisons are delegated to a new class > (o.a.v.runtime.parser.MathUtils). All operations are done using > primitives (as far as possible) and NOT BigInteger / BigDecimal like the > first proposal did. I added overflow checking all along the way (where > possible). In addition to that I removed the "paradigm of the smallest > type" where add (new Integer(1), new Integer(2)) would result in a > Byte(3). Now types are preserved as far as possible (overflow, mixing of > types). You find a lot of documentation about that in the javadoc > (MathUtils.java). Finally, overall, there should be no performance drawback. > There are also some new testcases and existing ones are updated (mostly > template based like math.vm). > So we (I hope Will doesn't mind me talking in his name) think this patch > will increase the usability of velocity a lot and hope that the others > like it too. > Open for discussion... > Regards > Peter -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]