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

List:       poi-dev
Subject:    [Bug 62506] Wrong implementation of truncation
From:       bugzilla () apache ! org
Date:       2018-06-28 15:31:51
Message-ID: bug-62506-47293-8GFknJG6LP () https ! bz ! apache ! org/bugzilla/
[Download RAW message or body]

https://bz.apache.org/bugzilla/show_bug.cgi?id=62506

duffy duck <c.dellacqua@bravosolution.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |NEW

--- Comment #2 from duffy duck <c.dellacqua@bravosolution.com> ---
Hi,
we have executed the following test:

with 10.000.000 iterations the execution time is changed from 800ms to 4s. 

Random r = new Random();
double result;
int loopNumber = 10000000;
long startTime = System.currentTimeMillis();
// 800 ms
for (int i=0; i<loopNumber; i++) {
   double d0 = r.nextDouble();
   double d1 = r.nextInt(5);
   double multi = Math.pow(10d, d1);
   if (d0 < 0)
      result = -Math.floor(-d0 * multi) / multi;
   else
      result = Math.floor(d0 * multi) / multi;
}
long lapTime = System.currentTimeMillis();
System.out.println("Old calculation for " + loopNumber + " occurrence take " +
(lapTime-startTime) +" ms");

// 4s
for (int i=0; i<loopNumber; i++) {
   double d0 = r.nextDouble();
   double d1 = r.nextInt(5);
   result = new
BigDecimal(Double.toString(d0)).setScale((int)d1,BigDecimal.ROUND_DOWN).doubleValue();
}
long endTime = System.currentTimeMillis();
System.out.println("New calculation for " + loopNumber + " occurrence take " +
(endTime-lapTime) +" ms");

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org

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

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