pi and floating numbers

new BookmarkLockedFalling
davos1
Guest

Guest Avatar

Post by davos1 on Jan 24, 2009 23:48:06 GMT -5

Hi, :)
is there a way to use floating numbers or high precision numbers in run basic?
It seems that numbers are truncated to 8 decimals.
for example I entered a pi value:

pi=3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303820
print str$(pi) -->outputs 3.14159265

print len(str$(pi)) -->outputs 10 ("3." plus 8 decimals)
print using("###.#######################################################################################################################################################################################################",pi)
here the output is any another other number:
3.1415926535897941666764061799003196457407267770559370466063992573254025652689983941031662858642277781295157467407790749710221960300978624104036248025100991404062298709315003240486150017521864002240512

thanks a lot

Alberto
Last Edit: Jan 26, 2009 2:30:27 GMT -5 by StefanPendl
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550

Post by Carl Gundel - admin on Jan 26, 2009 8:37:57 GMT -5

You've got 15 digits of precision there which about what you can expect from double precision math with Run BASIC. The rest of the digits are from the rendering algorithm trying to estimate the rest of the value, something it doesn't do very well obviously.

Run BASIC does allow for arbitrarily large integers, but not so for floating point numbers.

-Carl
davos1
Guest

Guest Avatar

Post by davos1 on Jan 26, 2009 16:37:27 GMT -5

Thanks, ;D
Using it like integer works fine.
ci=3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086512823066470938446095505822317253594081284811174502841027019385211055596446229489549303820
print using("########################################################################################################### ###############################################################################################",ci)
result->
3141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086512823066470938446095505822317253594081284811174502841027019385211055596446229489549303820




Stefan: please use code and quote boxes for very long lines, so they include a horizontal scrollbar or wrap the text nicely
Last Edit: Jan 27, 2009 1:34:34 GMT -5 by StefanPendl
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550