You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by de...@thelanguageshop.org on 2021/02/27 20:32:34 UTC

remove me


-----------------------------------
Deborah Lockhart
Director of Operations
The Language Shop
www.thelanguageshop.org
Tel: + 1 646 245 4129
Fax: + 1 718 641 7667

The Language Shop is a full service language solutions provider. When you engage the services of The Language Shop, you agree to allow us to respond to all issues and questions you may have regarding any project that we may complete for you. The Language Shop reserves the right to take credit for all of its work.
 
The information contained in this email and any attachment is private and is intended solely for the named recipient(s) and may contain confidential and/or privileged information. For those other than the recipient, any disclosure, dissemination, copying or distribution is strictly prohibited. If you have received this email in error, please delete the message from your computer and inform the sender immediately.

Any views expressed in this message and any attachments are those of the individual sender and not necessarily those of The Language Shop.

WARNING: Whilst The Language Shop has taken every reasonable precaution to minimize the risk of viruses, we cannot accept liability for any damage, which you sustain as a result of software viruses. You should therefore carry out your own virus checks before opening any attachment. 

This message is not intended to be spam.  If you do not wish to receive any more e-mails, please reply with the words "Remove Me" in the subject line.
Important Privacy Note: I hate spam just as much as you do. That's why your information is safe with me.  I'll never reveal, sell, rent, lease, or otherwise disclose your email to anyone! No ifs, buts, or ands about it! That's my personal promise to you.
 
Please consider the environment before you print this e-mail.


-----Original Message-----
From: Claude Brisson (Jira) [mailto:dev@velocity.apache.org] 
Sent: Saturday, February 27, 2021 3:29 PM
To: dev@velocity.apache.org
Subject: [jira] [Resolved] (VELTOOLS-182) MathTool.max longtime bug with args (0,0)


     [ https://issues.apache.org/jira/browse/VELTOOLS-182?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claude Brisson resolved VELTOOLS-182.
-------------------------------------
    Fix Version/s: 3.1
         Assignee: Claude Brisson
       Resolution: Fixed

Fixed

> MathTool.max longtime bug with args (0,0)
> -----------------------------------------
>
>                 Key: VELTOOLS-182
>                 URL: https://issues.apache.org/jira/browse/VELTOOLS-182
>             Project: Velocity Tools
>          Issue Type: Bug
>          Components: GenericTools
>    Affects Versions: 2.0
>            Reporter: Sanford Whiteman
>            Assignee: Claude Brisson
>            Priority: Major
>             Fix For: 3.1
>
>
> It appears that {{$math.max}} has had a bug since at least 2.0, or at least I'm at a loss as to why the observed behavior would be expected, and it doesn't appear to be documented.
>  
> {code:java}
> $math.max(0,0) {code}
>  
> returns
>  
> {code:java}
> 4.9E-324{code}
>  
> that is, Double.MIN_VALUE.
>  
> It's easy to see why in the source. Using [3.0|https://apache.googlesource.com/velocity-tools/+/trunk/velocity-tools-generic/src/main/java/org/apache/velocity/tools/generic/MathTool.java#377] here, we see:
>  
> {code:java}
>     public Number max(Object... nums)
>     {
>         double value = Double.MIN_VALUE;
>         Number[] ns = new Number[nums.length];
>         for (int i=0; i<nums.length; i++)
>         {
>             Number n = toNumber(nums[i]);
>             if (n == null)
>             {
>                 return null;
>             }
>             value = Math.max(value, n.doubleValue());
>             ns[i] = n;
>         }
>         return matchType(value, ns);
>     }
> {code}
>  
> So rather than delegating to {{Java.lang.Math.max}} directly, each iter takes the {{Math.max}} of the current value and Double.MIN_VALUE. Ergo, if the arguments are 0, that's always < Double.MIN_VALUE, so the result is in turn Double.MIN_VALUE.
> The same goes for {{$math.max(0)}} (just one arg) but at least that could be considered a usage error.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org



-- 
This email has been checked for viruses by AVG.
https://www.avg.com


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org