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: for loop

Previous Thread :: Next Thread 
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 11:27 PM
for i = 1, 10, .3 do
print(i)
end

This prints 1 - 9.7

But if I do

for i = 1, 10.1, .3 do
print(i)
end

It prints 1 - 10

Why is this?
Report Abuse
AgentFirefox is not online. AgentFirefox
Top 100 Poster
Joined: 20 Jun 2008
Total Posts: 22404
12 Jan 2013 11:30 PM
Because the value is not exactly 10. It's ~` 10.000000001, which is NOT 10. So it doesn't print.

Your increment is not exactly .3. It's somewhere between .299999999 and .30000001, but not exactly .3.
Report Abuse
CodyTheBuildingKid is not online. CodyTheBuildingKid
Joined: 13 Dec 2011
Total Posts: 4399
12 Jan 2013 11:33 PM
qq
This is good to know.
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
13 Jan 2013 12:07 AM
And, for the first example, it worked because .3 goes into 9 without a remainder.
Why 9? Because 10 - 1 is 9.

The second example only printed to 10 because .3 doesn't go into 9.1.
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