generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Tonumber has failed me :(

Previous Thread :: Next Thread 
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
27 Jul 2015 09:00 PM
Number = 104912345432191072912345432190912345432190912345432198432151234813743212347000001907349912345432190743212347591234543219074321234730000001192093912345432191912345432192912345432192912345432192912345432190912345432190912345432190912345432190912345432190912345432190

print(tonumber(Number))


>1.0491234543219e+263 -- Wut? I want the full value back :(
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jul 2015 09:01 PM
print(string.format("%18.0f",Number))
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
27 Jul 2015 09:03 PM
Eh, probably an issue with double rounding or something along those lines. Why do you need to use tonumber on such a stupidly huge number?

~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
27 Jul 2015 09:04 PM
encoding parts into numbers for infinite datastores
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
27 Jul 2015 09:06 PM
doesn't format properly
>104912345432191070000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jul 2015 09:06 PM
Number is still that number it's just in scientific notation when tostringed.

btw tonumbering a number and then printing it was kind of useless since print just tostrings it lol.


But when you're outputting it simply use the string.format thing I gave you
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
27 Jul 2015 09:07 PM
I thought datastores were encoded into JSON, so what affect would this have?

~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
27 Jul 2015 09:08 PM
Try

print(string.format("%.0f", Number))
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
27 Jul 2015 09:08 PM
i need to to number it since a number doesn't have a datalimit in a datastore?

Perhaps we can fenv it? Idk how
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
27 Jul 2015 09:10 PM
still returns same thing
Report Abuse
lego555444 is not online. lego555444
Joined: 21 Sep 2008
Total Posts: 1383
27 Jul 2015 09:20 PM
My post wouldn't go through for some reason so I took a picture of it;

gyazo(DOT)com/e4d9f86c4b268f09aeb9deb1b12f4793
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
27 Jul 2015 09:20 PM
Data is data... datastores have a DATA limit.

Numbers are data too.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
27 Jul 2015 09:21 PM
http://wiki.roblox.com/index.php?title=JSON
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
27 Jul 2015 09:21 PM
He was calling tonumber() because he thought it'd return the full number. He didn't realize 1.0491234543219e+263 was still of the number datatype.

Yeah, sorry, there's only so much data you can fit into 64 bits, and you're going to have some floating point precision issues.

I don't know what exactly you're trying to do so no one here can give you an alternative.
Report Abuse
thedestroyer115 is not online. thedestroyer115
Joined: 19 Dec 2010
Total Posts: 11546
27 Jul 2015 09:23 PM
You can also try to save it as a string.
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
27 Jul 2015 09:36 PM
...which will accomplish nothing, because it's all converted into a string anyways ;)

~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~
Report Abuse
lordrambo is not online. lordrambo
Joined: 16 Jun 2009
Total Posts: 20628
27 Jul 2015 09:48 PM
If you initially make it a string it won't turn into scientific notation, which is what he meant.
Report Abuse
DeveloperBlue is online. DeveloperBlue
Joined: 15 Apr 2009
Total Posts: 1344
27 Jul 2015 10:08 PM
A hacky way would be to convert to string, chop it into little pieces every 20th digit, and save it in a table.
Report Abuse
DeveloperBlue is online. DeveloperBlue
Joined: 15 Apr 2009
Total Posts: 1344
27 Jul 2015 10:09 PM
Wait, why do you need a number so large o-o
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
28 Jul 2015 04:46 AM
Precision is lost, computers can't store numbers in an infinite amount of bytes.
Report Abuse
nicemike40 is not online. nicemike40
Joined: 19 Dec 2008
Total Posts: 1814
28 Jul 2015 04:24 PM
Even more fun: any integer above 2^53 (about 9 quadrillion) is not guaranteed to maintain precision, but the highest possible number (which is an integer obviously) is around 1.79e308.

Try it yourself:

print(1.7e308) --> 1.7e+308
print(1.8e308) --> 1.#INF (infinity)

~Upload code to codepad-dot-org with Lua syntax highlighting to preserve indentation and make it easier to read!~
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
28 Jul 2015 04:47 PM
53 bits of precision for IEEE-754 doubles, which is why we need Lua 5.3 for the integer datatype so we have 63/64 bits of precision for integers. Believe it or not, 11 bits more of precision makes a HUGE difference.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image