Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.5
    • Fix Version/s: None
    • Component/s: Engine
    • Labels:
      None
    • Environment:
      Operating System: other
      Platform: Other

      Description

      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

      1. ASF.LICENSE.NOT.GRANTED--arithmetic.patch
        196 kB
        Peter Romianowski
      2. ASF.LICENSE.NOT.GRANTED--arithmetic.patch
        247 kB
        Peter Romianowski
      3. ASF.LICENSE.NOT.GRANTED--number-patch2.patch
        172 kB
        Will Glass-Husain

        Activity

        No work has yet been logged on this issue.

          People

          • Assignee:
            Unassigned
            Reporter:
            Peter Romianowski
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development