General > General Technical Chat

What calculator do you use ?

<< < (24/84) > >>

slateraptor:

--- Quote from: HAL-42b on April 24, 2012, 03:50:42 am ---On a side note here is something that I wasn't aware of until recently. A NOVA film from 1985 about some of the more intricate and controversial aspects of mathematics.

--- End quote ---

That video was fun. Thanks for indirectly coercing me into burning away an hour of productivity. :P

HLA-27b:

--- Quote from: slateraptor on April 24, 2012, 05:08:04 am ---That video was fun. Thanks for indirectly coercing me into burning away an hour of productivity. :P

--- End quote ---

What do you mean,
Burning away an hour in order to produce productivity, or
Burning away productivity in order to produce an hour?  ;D

cybergibbons:

--- Quote from: IanB on April 24, 2012, 01:41:20 am ---
--- Quote from: ejeffrey on April 23, 2012, 01:13:55 pm ---The problem is simply that (binary) floating point arithmetic of any precision is unsuitable for financial transactions because certain values are not representable.  You can't represent $0.10 exactly in as floating point number.  When written in base 2, the number 1/10 is an infinitely repeating fraction, so it can't be captured exactly with any finite width number.
--- End quote ---

This argument is entirely bogus. How do you represent $10/3 exactly in BCD? It's just as impossible as representing $0.10 in binary.

It doesn't matter, you argue? Well what happens with interest calculations? Suppose you need to add 5.7% per annum to a balance on a monthly basis. Are you going to do that precisely in BCD? Not a chance!

Ultimately the only way to get decently accurate answers is to use enough extra digits of precision (and careful arrangement of calculation order) so that rounding errors are insignificant. It ultimately makes no difference whether you do that in BCD or in binary. The results will be identical.

For instance, this is what my (binary) calculator says about 200000 * (1 + 0.06/360)^(360*30): 1209748.03723

Apparently binary arithmetic works.

--- End quote ---

The problem is with floating point arithmetic using binary representation, not with binary arithmetic. It is certainly an issue. IEEE floating point can't represent the most basic of numbers in base 10 with decent precision.

Most languages, if you do something like provide 2.35, will convert to floating point, and then when displayed back you will get 2.3500000000000001. There are lots of examples of this on the internet.

Normally the biggest issue isn't the accumulation of errors as numbers grow, but the fact they rarely cancel out. You end up with tiny balances of 0.000000000000001.

BCD means that the errors you see are the same as with base 10 systems. 0.1 = 0.1. 1/3 = 0.3333333333. You can accurately represent any two decimal place number in BCD, but not with floating point.

ejeffrey:

--- Quote from: IanB on April 24, 2012, 01:41:20 am ---This argument is entirely bogus. How do you represent $10/3 exactly in BCD? It's just as impossible as representing $0.10 in binary.

--- End quote ---

That is true, but irrelevant.  You never make a transaction of $10/3, but you do make transactions of $.10.  You can't have 3 1/3 dollars in your bank account.  If you buy oranges 3/$1, one costs $.33, not $.33333.  Two cost $.67.  If you buy one today and come back for one tomorrow, they each cost $.33 -- you don't still owe the merchant an ephemeral third of a penny.


--- Quote ---It doesn't matter, you argue? Well what happens with interest calculations? Suppose you need to add 5.7% per annum to a balance on a monthly basis. Are you going to do that precisely in BCD? Not a chance!

--- End quote ---

At every compounding period, you round the interest to the nearest penny.  Something you can't do if the balance is represented as dollars in floating point. 


--- Quote ---Ultimately the only way to get decently accurate answers is to use enough extra digits of precision (and careful arrangement of calculation order) so that rounding errors are

--- End quote ---

My point, which you completely missed, is that financial calculations do not need extreme accuracy in the sense that scientists and engineers are used to.  They need a specifically defined behavior which can only be accomplished through the use of integer or BCD arithmetic and correct coding.


--- Quote ---insignificant. It ultimately makes no difference whether you do that in BCD or in binary. The results will be identical.

--- End quote ---

No, they wont.


--- Quote ---For instance, this is what my (binary) calculator says about 200000 * (1 + 0.06/360)^(360*30): 1209748.03723

--- End quote ---

Unfortunately, that is wrong.  Well, you have correctly calculated the given expression to the desired precision, but that is not the answer you get if you deposit $200,000 in a bank account with 6% interest compounded daily for 30 years of 360 days (!).  The answer to that question would be the recurrence relation:


--- Code: ---x_0 = 200,000
y_n = x_{n-1} * (0.06/360)
x_n = x_{n-1} + y_n

--- End code ---

Where x_n is the balance on the nth day, and y_n is the interest payment on the nth day, which should be rounded to the penny.  This is the only way that your balance (and the bank's balance which isn't shown) are legal values at the end of every day.

The end result is: $1,209,748.66 -- although I am still not 100% sure I got the rounding correct (round to nearest with ties going to the even number) since I was using integer arithmetic.  You end up with a bit more than if you solve the the entire problem with high precision and then round at the end, because for the specific values chosen you happen to win a few more times than you lose on the rounded penny.

saturation:
I just tried some of these tests:

https://www.eevblog.com/forum/general-chat/what-calcultator-do-you-use/msg106609/#msg106609

On freeware RealCalc on Android.  Its >= to my Casios, and its free.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod