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 » Scripting Helpers
Home Search
 

Re: What's wrong with zero?

Previous Thread :: Next Thread 
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
25 May 2012 09:32 PM
I tried typing in:

print(math.sin(math.pi))

And instead of getting the correct answer of zero, I got:

1.2246063538224e-016

But sure enough, I tried:

print(math.sin(math.pi)+.1)

And got:

.1

So why can't it just display 0?
Report Abuse
L2000 is not online. L2000
Joined: 03 Apr 2008
Total Posts: 77448
25 May 2012 09:37 PM
I'm guessing it's due to having something like 0.00000000000000000001.

Since rounding it wouldn't give a correct answer (It would give that it has no value, while it does), it has to give the 1.22...e-016 value. Then, when you add 0.1, it can round down to 0.1 and still have a somewhat accurate answer, so it works.

So, basically, it can't be rounded down to 0.
Report Abuse
200AB is not online. 200AB
Joined: 24 Aug 2010
Total Posts: 1604
25 May 2012 09:38 PM
My guess is because it's trying to put it in radians.
Report Abuse
imcoolfire8 is not online. imcoolfire8
Joined: 23 Nov 2009
Total Posts: 3008
25 May 2012 09:42 PM
Use math.floor

♪ Can you dig it? ♪
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
26 May 2012 12:36 AM
"+.1"

That part that you added to the end of the conversion will explain it.
Report Abuse
pwnedu46 is not online. pwnedu46
Joined: 23 May 2009
Total Posts: 7534
26 May 2012 12:42 AM
Sorry, I misread your post. I think it has something to do with the rounding.
Report Abuse
3lex33 is not online. 3lex33
Joined: 08 Oct 2008
Total Posts: 5220
26 May 2012 03:07 AM
1.2246063538224e-016

e-016 means that that long number(1.2246063538224) is multiplied by (1/(10^16)), which is incredibly small number. I can only guess that roblox follows high math and auto replaces zero with very small number. To fix it, as other said, use math.floor
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
26 May 2012 11:54 AM
Wierd, I tried typing in

print(math.sin(3.14159265))

And I got 0

The big problem is: I am making a calculator, so I can't just take the equation and floor it incase someone did 2-1.5 or something. I tried this:

if ans+1 == 1 then display 0

But apparently,

math.sin(math.pi)+1 ~= 1

So now I have a big problem. Maybe I should use the first 50 digits for pi instead of math.pi.
Report Abuse
BunnyBoy26 is not online. BunnyBoy26
Joined: 17 Jun 2010
Total Posts: 5674
26 May 2012 11:58 AM
gaghagh. Apparently that method isn't working anymore.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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