Package: org.apache.poi.ss.formula.eval
Class: TwoOperandNumericOperation
public static final Function MultiplyEval = new
TwoOperandNumericOperation() {
protected double evaluate(double d0, double d1) {
return d0*d1;
}
};
Using double for multiplication is not helping when using it for money
calc
On Thu, 14 Aug 2014, Venkatraman Suresh wrote:
For instance product of 199.1 and 38.15 results to 7595.6649
Is there a plan to fix this?
That's just how floating point works, sorry...
Try setting a format string on the resulting cell, just as you would in
Excel, so it stays formatted
rsday, August 14, 2014 3:56 PM
To: POI Users List
Subject: Re: Product of 199.1 and 38.15 gives 7595.6649
On Thu, 14 Aug 2014, Venkatraman Suresh wrote:
> For instance product of 199.1 and 38.15 results to 7595.6649
>
> Is there a plan to fix this?
That's just how floating
On Thu, 14 Aug 2014, Crocker, David wrote:
That doesn't make sense to me. I could see how it would be true if the
number turned out to be, say, 7595.6650003, but I thought that
floating point calculations were working correctly in Java.
Your two input numbers probably aren't what you thin
And you can round first. This looks like a good link:
http://stackoverflow.com/questions/153724/how-to-round-a-number-to-n-decimal-places-in-java
Dave
> Your two input numbers probably aren't what you think they are, I'd suspect
> they're actually already rounded
> Try with .xlsx, as you can
double c3 = 199.1;
double c4 = 38.15;
c3*c4 will give 7595.6649
Formatting to two decimal places may not work as it would result in 7595.66
but I need the response to be 7595.67 when rounding to 2 decimals.
Thanks
Venkat
On Thu, Aug 14, 2014 at 3:17 PM, Crocker, Davi
This is a BUG. Is there any plan to fix it?
Thanks
Venkat
On Thu, Aug 14, 2014 at 3:56 PM, Venkatraman Suresh
wrote:
> double c3 = 199.1;
> double c4 = 38.15;
> c3*c4 will give 7595.6649
>
> Formatting to two decimal places may not work as it would result in
> 7595.66 b
Venkat,
in my opinion you are just facing floating point arithmetics. The
correct solution is in Java, not in POI.
Please see below.
Best regards
Andreas
public static void main(String args[]) {
double c3 = 199.1;
double c4 = 38.15;
System.out.println(c3);
System.out.println
On Wed, 20 Aug 2014, Venkatraman Suresh wrote:
This is a BUG. Is there any plan to fix it?
I'm still not sure it is a bug. Numbers in Excel are (except for a few
edge cases) stored as floating point numbers. POI therefore matches Excel
and uses floating point numbers to store and manipulate t
Nick,
My Excel (2013, 32-bit) running under Windows 8 (64-bit) yields:
199.1 * 38.15 = 7,595.66500
which it of course rounds to 7,595.67
(& finds exactly equal to 7,595.665)
So Excel is presumably doing something more than just multiplying doubles
together.
You could do
(this was bounced while sent from nabble, so although a bit duplicate to
DaveLaw post, but maybe still interesting ...)
Nick Burch-2 wrote
> I've just fired up open office, put 199.1 in A1, 38.15 in B1, put =A1*B2
> in C1, and got (with a suitable formatting rule) 7595.6649, which
> is
11 matches
Mail list logo