[Info-vax] Programming languages on VMS

Arne Vajhøj arne at vajhoej.dk
Wed Jan 31 21:21:01 EST 2018


On 1/31/2018 7:05 PM, seasoned_geek wrote:
> On Wednesday, January 24, 2018 at 2:21:43 PM UTC-6, Arne Vajhøj
> wrote:
>> On 1/24/2018 11:11 AM, John Reagan wrote:
>>> I wouldn't do currency manipulation in anything but COBOL.  I've
>>> seen too many people get it wrong when trying to do it in
>>> another language.
>> 
>> Cobol was a bit unique in that regard 25+ years ago.
>> 
>> But today most likely alternative languages has types for that: 
>> Java BigDecimal, C# decimal, VB.NET Decimal, C++ various fixed 
>> point classes, Python supposedly have a decimal, even PHP has money
>> libraries.
>> 
> 
> None of those are suitable for large scale financial transactions.
> Under the hood they are complete sh*t. It's been a bit since I looked
> under the hood, but last time I checked the __all__ use an IEEE
> floating point then thump it down to however many decimal places.

No.

Java BigDecimal and C#/VB.NET does not use IEEE floating point
(and never has).

https://docs.oracle.com/javase/8/docs/api/java/math/BigDecimal.html

<quote>
Immutable, arbitrary-precision signed decimal numbers. A BigDecimal 
consists of an arbitrary precision integer unscaled value and a 32-bit 
integer scale. If zero or positive, the scale is the number of digits to 
the right of the decimal point.
</quote>

https://msdn.microsoft.com/en-us/library/system.decimal(v=vs.110).aspx

<quote>
The binary representation of a Decimal value consists of a 1-bit sign, a 
96-bit integer number, and a scaling factor used to divide the 96-bit 
integer and specify what portion of it is a decimal fraction.
</quote>

Have you ever considered actually learning a little bit about topics
before you comment on them?

> When you introduce the floating point you introduce the error. The
> things you mention were written for academics to write 5 line example
> programs which will never be in production anywhere.

Well - those features (at least Java BigDecimal and C# decimal) are in
production use many places..

Arne



More information about the Info-vax mailing list