Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql General > Re: rounding pr...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 22 of 36 Topic 15511 of 17437
Post > Topic >>

Re: rounding problems

by justin@[EMAIL PROTECTED] (Justin) May 13, 2008 at 01:29 PM

This is a multi-part message in MIME format.
--------------070604040404030402020707
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit


Tomasz Ostrowski wrote:
> On 2008-05-13 17:29, Justin wrote:
>   
>> Tomasz Ostrowski wrote:
>>     
>>> On 2008-05-12 20:49, Justin wrote:
>>>
>>>   
>>>       
>>>> We take (List Price * discount Percent) * Number of Pieces = net
>>>> price.
>>>>     
>>>>         
>>> This is wrong. You should do in Excel:
>>> ( price * amount ) * discount
>>> As otherwise any small error in representation of price*discount would
>>> be multiplied by usually high amount.
>>>   
>>>       
>> Your saying in Excel,  Multiplication is not  Commutativity???  that
>> sends shudders  down my back
>>     
>
> On floats it is not in any language. Try this C program:
>
> #include <stdio.h>
>
> int main()
> {
>         float a = 0.1;
>         float b = 10;
>         float c = 1000000000;
>         float d = a * b;
>         printf("%.10f\n", d*c);
>         d = b * c;
>         printf("%.10f\n", a*d);
>         return 0;
> }
>
> On my Intel 32-bit I get:
> 1000000000.0000000000
> 1000000014.9011611938
>   
I ran this on Windows using MSVC

The Result are the same when using float .  But the Ms compiler throws 
warnings, crying  truncation and rounding problems
1000000000.0000000000
1000000014.9011612000

I change it to double  problem goes away.
1000000000.0000000000
1000000000.0000000000

I have always avoided floating points.  In all the work i have done thus 
far the problems with floating math would  cause scrap parts or make 
Quality control worthless. 

Accuracy trumps pretty much every concern around here.


> Pozdrawiam
> Tometzky
>   

--------------070604040404030402020707
Content-Type: text/html; charset=ISO-8859-2
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-2" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
<br>
Tomasz Ostrowski wrote:
<blockquote cite="mid:4829C135.6010905@[EMAIL PROTECTED]
" type="cite">
  <pre wrap="">On 2008-05-13 17:29, Justin wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">Tomasz Ostrowski wrote:
    </pre>
    <blockquote type="cite">
      <pre wrap="">On 2008-05-12 20:49, Justin wrote:

  
      </pre>
      <blockquote type="cite">
        <pre wrap="">We take (List Price * discount Percent) * Number of
Pieces = net
price.
    
        </pre>
      </blockquote>
      <pre wrap="">This is wrong. You should do in Excel:
( price * amount ) * discount
As otherwise any small error in representation of price*discount would
be multiplied by usually high amount.
  
      </pre>
    </blockquote>
    <pre wrap="">Your saying in Excel,  Multiplication is not 
Commutativity???  that
sends shudders  down my back
    </pre>
  </blockquote>
  <pre wrap=""><!---->
On floats it is not in any language. Try this C program:

#include &lt;stdio.h&gt;

int main()
{
        float a = 0.1;
        float b = 10;
        float c = 1000000000;
        float d = a * b;
        printf("%.10f\n", d*c);
        d = b * c;
        printf("%.10f\n", a*d);
        return 0;
}

On my Intel 32-bit I get:
1000000000.0000000000
1000000014.9011611938
  </pre>
</blockquote>
I ran this on Windows using MSVC<br>
<br>
The Result are the same when using float .  But the Ms compiler throws
warnings, crying  truncation and rounding problems <br>
1000000000.0000000000<br>
1000000014.9011612000<br>
<br>
I change it to double  problem goes away. <br>
1000000000.0000000000<br>
1000000000.0000000000<br>
<br>
I have always avoided floating points.  In all the work i have done
thus far the problems with floating math would  cause scrap parts or
make
Quality control worthless.  <br>
<br>
Accuracy trumps pretty much every concern around here.<br>
<br>
<br>
<blockquote cite="mid:4829C135.6010905@[EMAIL PROTECTED]
" type="cite">
  <pre wrap="">Pozdrawiam
Tometzky
  </pre>
</blockquote>
</body>
</html>

--------------070604040404030402020707--
 




 36 Posts in Topic:
rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 13:48:16 
Re: rounding problems
lyeoh@[EMAIL PROTECTED]   2008-05-13 02:07:09 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 14:54:47 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 15:08:11 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 04:29:06 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 17:02:30 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 17:09:57 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 17:23:15 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 05:50:16 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 18:37:02 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-12 19:04:13 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-13 02:20:18 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 22:51:42 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 11:42:09 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 00:16:06 
Re: rounding problems
xof@[EMAIL PROTECTED] (C  2008-05-12 14:53:21 
Re: rounding problems
craig@[EMAIL PROTECTED]   2008-05-13 05:26:46 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-12 14:18:57 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-12 14:49:48 
Re: rounding problems
tometzky@[EMAIL PROTECTED  2008-05-13 08:40:41 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 11:30:48 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 13:29:07 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 14:36:18 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-14 15:38:17 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-14 11:47:52 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-14 17:26:30 
Re: rounding problems
sam@[EMAIL PROTECTED] (S  2008-05-14 20:27:19 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-14 16:02:32 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-14 16:08:54 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-14 16:24:58 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-14 16:55:49 
Re: rounding problems
glene77is <glen.e77is@  2008-05-20 03:19:20 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-20 10:28:28 
Re: rounding problems
aanderson@[EMAIL PROTECTE  2008-05-12 15:56:30 
Re: rounding problems
justin@[EMAIL PROTECTED]   2008-05-13 13:01:11 
Re: rounding problems
doug@[EMAIL PROTECTED] (  2008-05-13 12:12:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 12:03:40 CST 2008.