On 26 March 2013 19:49, Luc Maisonobe <luc.maison...@free.fr> wrote:
> Le 26/03/2013 16:08, sebb a écrit :
>> On 26 March 2013 14:56,  <l...@apache.org> wrote:
>>> Author: luc
>>> Date: Tue Mar 26 14:56:01 2013
>>> New Revision: 1461159
>>>
>>> URL: http://svn.apache.org/r1461159
>>> Log:
>>> FastMath.abs() without branching for float and double primitive types.
>>>
>>> JIRA: MATH-954
>>>
>>> Modified:
>>>     
>>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
>>>
>>> Modified: 
>>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
>>> URL: 
>>> http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java?rev=1461159&r1=1461158&r2=1461159&view=diff
>>> ==============================================================================
>>> --- 
>>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
>>>  (original)
>>> +++ 
>>> commons/proper/math/trunk/src/main/java/org/apache/commons/math3/util/FastMath.java
>>>  Tue Mar 26 14:56:01 2013
>>> @@ -3011,10 +3011,7 @@ public class FastMath {
>>>       * @return abs(x)
>>>       */
>>>      public static float abs(final float x) {
>>> -        if ((Float.floatToRawIntBits(x) & Integer.MIN_VALUE) == 0) {
>>> -            return x;
>>> -        }
>>> -        return -x;
>>> +        return Float.intBitsToFloat(Integer.MAX_VALUE & 
>>> Float.floatToRawIntBits(x));
>>
>> It looks wrong using MAX_VALUE as a mask (even though the value is correct).
>> Is there a no better constant?
>>
>> If not, it would be better to create one with appropriate Javadoc.
>
> You are right.
> I have fixed that with new constants (see r1461283).

Thanks, that looks much better.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org
For additional commands, e-mail: dev-h...@commons.apache.org

Reply via email to