RE: Proposal to change default float type to decimal

"Mark Hahn" <[email protected]> Thu, 5 Aug 2004 12:14:47 -0700
Newsgroups gmane.comp.lang.prothon.user
Message-ID <000801c47b20$792c1ac0$0b01a8c0@mark>
I have learned more about the decimal type in .Net.  It only has values from
approximately 7e-28 to 7e28, so it cannot replace a real float.  It also has
no math library and can only do the basic C operations.

So I'd like to refine the proposal:

Numeric constants containing only a decimal point would become a Decimal
type: 1.354, 3452.7862.  Any constant with the letter e would be a normal
binary Float type:  1e37, 1.23e17.  There would be no constants with the
letter f like 1f34.

Decimal calculations that overflowed the range of 7e28 or 7e-28 (like
0.0000_0000_0000_0000_0000_0000_0000_7 / 2) would throw an exception instead
of automatically converting to Float.

The math module would automatically convert Decimal arguments to Float for
things like sin and log, just as it does with Int arguments.

This would still solve the gotcha:  0.1 + 0.1 would equal 0.2 exactly.  For
that matter, any constant or expression (not including a divide) that didn't
overflow the 28 digit precision would have an exact representation.