Page 1 of 1
[Implemented] float declaration by mantisse & exponent
Posted: Fri Jun 25, 2004 11:59 am
by Froggerprogger
Sometimes I miss another way to define Floats, by mantisse & exponent: e.g.
Code: Select all
a.f = 1.423543e-12
b.f = 1234.2345E42
(with both 'e' or 'E' possible and more than one digit in front of the '.')
Posted: Fri Jun 25, 2004 12:30 pm
by Dummy
Good Idea!
I think that wouldn't be that hard to realize and would increase the C -> PureBasic portability!
Posted: Fri Jun 25, 2004 12:59 pm
by Froggerprogger
This would even increase the QBasic -> PB portability.
Atm it is not possible to define some physical constants directly.
E.g. I defined 1 eV = 1.602e-19 by the lines:
Code: Select all
a.f = 1.602
For i=1 to 19
a/10
Next
debug StrF(a, 30)
Further the StrF() could give a mantisse/exponent - formatted String when using -1 as Value for the NBDecimals, or even more consistent in my eyes:
StrF(a.f) should give the mantisse/exponent-representation, and
StrF(a.f, NBDecimals) should give the rational representation with the specified number of post-comma-digits.
This shouldn't be hard to implement, because the float-format already contains the values for sign/mantisse/exponent seperately in it's binary representation.