[prev in list] [next in list] [prev in thread] [next in thread] 

List:       jakarta-commons-dev
Subject:    [jira] Resolved: (MATH-154) MathUtils addAndCheck and subAndCheck
From:       "Brent Worden (JIRA)" <jira () apache ! org>
Date:       2007-10-31 7:22:50
Message-ID: 24776761.1193815370647.JavaMail.jira () brutus
[Download RAW message or body]


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

Brent Worden resolved MATH-154.
-------------------------------

    Resolution: Fixed

Added addAndCheck, mulAndCheck, and subAndCheck MathUtils methods for long integer \
arguments.


> MathUtils addAndCheck and subAndCheck for long values
> -----------------------------------------------------
> 
> Key: MATH-154
> URL: https://issues.apache.org/jira/browse/MATH-154
> Project: Commons Math
> Issue Type: Improvement
> Affects Versions: 1.1, Nightly Builds
> Reporter: Remi Arntzen
> Fix For: 1.2
> 
> Attachments: MathUtils.diff, MathUtils.diff
> 
> 
> public static long addAndCheck(long x, long y) {
> BigInteger s = BigInteger.valueOf(x).add(BigInteger.valueOf(y);
> if (s.bitLength() + 1 > Long.SIZE) {
> throw new ArithmeticException("overflow: add");
> }
> return s.longValue();
> }
> public static long subAndCheck(long x, long y) {
> BigInteger s = BigInteger.valueOf(x).subtract(BigInteger.valueOf(y));
> if (s.bitLength() + 1 > Long.SIZE) {
> throw new ArithmeticException("overflow: add");
> }
> return s.longValue();
> }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic