[Implemented] float declaration by mantisse & exponent

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

[Implemented] float declaration by mantisse & exponent

Post 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 '.')
%1>>1+1*1/1-1!1|1&1<<$1=1
Dummy
Enthusiast
Enthusiast
Posts: 162
Joined: Wed Jun 09, 2004 11:10 am
Location: Germany
Contact:

Post by Dummy »

Good Idea!

I think that wouldn't be that hard to realize and would increase the C -> PureBasic portability!
Froggerprogger
Enthusiast
Enthusiast
Posts: 423
Joined: Fri Apr 25, 2003 5:22 pm
Contact:

Post by Froggerprogger »

This would even increase the QBasic -> PB portability. :wink:

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.
%1>>1+1*1/1-1!1|1&1<<$1=1
Post Reply