A lot of Decimal Places

I

Israel Rodriguez

I was just checking the .NET C# Reference and found that the decimal
type is limited to 29 decimal places (seems to be the largest
on .NET):
http://msdn.microsoft.com/en-us/library/364x0z75.aspx

I'm developing a financial system, that calculates amount's of money
(with currency conversion) over almost 20 years...and my boss did the
old version of the system in Excel, and we foun that Excel uses over
100 decimal places (and after the years calculation, it's giving a lot
of difference). My question: Is there any way i can use more decimal
places on .NET?
 
P

Patrice

Hello,

I was just checking the .NET C# Reference and found that the decimal
type is limited to 29 decimal places (seems to be the largest
on .NET):
http://msdn.microsoft.com/en-us/library/364x0z75.aspx

I'm developing a financial system, that calculates amount's of money
(with currency conversion) over almost 20 years...and my boss did the
old version of the system in Excel, and we foun that Excel uses over
100 decimal places (and after the years calculation, it's giving a lot
of difference). My question: Is there any way i can use more decimal
places on .NET?

Humm. Really strange :

1) AFAIK Excel doesn't have such a precision. Where did you find this ? What
are you using in Excel ? Floating point values ?

2) 29 significant digits seems quite good (do you handle such huge amounts
of money ?)

For now I would say that the problem you see have some other cause (and
perhaps even that .NET results provide a better accuracy than the Excel
counterpart).
 
P

Peter Duniho

Patrice said:
Hello,



Humm. Really strange :

1) AFAIK Excel doesn't have such a precision. Where did you find this ? What
are you using in Excel ? Floating point values ?

You are correct, Excel does not have 100 digits of precision. It uses a
normal IEEE format and as documented in the Excel Help, it has about 15
digits of precision (i.e. IEEE double precision, 64 bits).

Perhaps the OP misread this article:
http://blogs.msdn.com/excel/archive...es-excel-give-me-seemingly-wrong-answers.aspx

....in which an example is given that _would_ need 100 digits of
precision for the correct answer, but which cannot be properly
calculated in Excel (or any other numerical program using the 64-bit
IEEE floating point format).
2) 29 significant digits seems quite good (do you handle such huge amounts
of money ?)

For now I would say that the problem you see have some other cause (and
perhaps even that .NET results provide a better accuracy than the Excel
counterpart).

That would be my guess too. If the OP wants the exact same answers that
Excel is calculating, he may need to use Double instead of Decimal. Of
course, if one is using floating point it should not be a concern to get
exactly identical results to the last significant digit. Otherwise, a
floating point format might not be the best choice for the calculations.

Pete
 
H

Harlan Messinger

Israel said:
I was just checking the .NET C# Reference and found that the decimal
type is limited to 29 decimal places (seems to be the largest
on .NET):
http://msdn.microsoft.com/en-us/library/364x0z75.aspx

I'm developing a financial system, that calculates amount's of money
(with currency conversion) over almost 20 years...and my boss did the
old version of the system in Excel, and we foun that Excel uses over
100 decimal places (and after the years calculation, it's giving a lot
of difference). My question: Is there any way i can use more decimal
places on .NET?

You do realize that the value of all the world's financial assets can be
represented in U.S. cents with no more than 20 digits?
 
A

Arne Vajhøj

Israel said:
I was just checking the .NET C# Reference and found that the decimal
type is limited to 29 decimal places (seems to be the largest
on .NET):
http://msdn.microsoft.com/en-us/library/364x0z75.aspx

I'm developing a financial system, that calculates amount's of money
(with currency conversion) over almost 20 years...

..NET Decimal is fine for that.
and my boss did the
old version of the system in Excel, and we foun that Excel uses over
100 decimal places (and after the years calculation, it's giving a lot
of difference).

I am 99.9% sure that the .NET result with decimal is the correct
one and the Excel one is the wrong one.

Excel does not have 100 digits of precision.
My question: Is there any way i can use more decimal
places on .NET?

F# comes with a BigInt and a BigNum class that should be usable from C#.

Arne
 
A

Arne Vajhøj

rossum said:
Java has a BigDecimal class which has essentially unlimited precision.
You may want to search for a .NET implementation of that class.

Or just use Java BigDecimal !

BigDecimal were in Java 1.1 so it is available in J# as well.

It works fine in C#.

Arne
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top