hello !

i take back here the pbwin thread http://www.powerbasic.com/support/pb...ead.php?t=7755

my wish would be that pb implements a 20 digit string representation of extended precision floats, and this both for output and input of data.

in the meantime here is an example of a function which seems to solve the output problem.

note that in the given example 20 digits of pi are given, and the last one is wrong by 1 unit.

the function is ugly and sloppy, involving many math and string operation, and probably buggy as well (i did very few tests).

is someone willing to take the challenge and write a better one ... and maybe write one for input ...?

regards

------------------

aldo vitagliano

mailto:[email protected][email protected]</a>

i take back here the pbwin thread http://www.powerbasic.com/support/pb...ead.php?t=7755

my wish would be that pb implements a 20 digit string representation of extended precision floats, and this both for output and input of data.

in the meantime here is an example of a function which seems to solve the output problem.

note that in the given example 20 digits of pi are given, and the last one is wrong by 1 unit.

the function is ugly and sloppy, involving many math and string operation, and probably buggy as well (i did very few tests).

is someone willing to take the challenge and write a better one ... and maybe write one for input ...?

Code:

declare function strext$(byval x as ext) defext a-z function pbmain() pi=4*atn(1) print "correct value of pi is 3.141592653589793238462643..." print "pwbasic printed pi is ";str$(pi,18) print "extended precis. pi is ";strext$(pi) print print "-0.01 - 1e-21 is "; print strext$(-0.01##-1e-21#) waitkey$ end function function strext$(byval x as ext) sg&=sgn(x): x=abs(x) a=int(log10(x)) b=100*x/10^a c=int(b) d=(b-c)*1e17# function=left$(str$(sg&),1)+"."+format$(c)+format$(d,"00000000000000000")+"e"+format$(a+1,"000") end function

------------------

aldo vitagliano

mailto:[email protected][email protected]</a>

## Comment