Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialErich Lehmann
Courses Plus Student 50 PointsHi! Can you help me please. I try to write float variables,but it doesn't work and i need help. Thanks a lot
sorry,can you help me please
2 Answers
Kai Aldag
Courses Plus Student 13,560 PointsFloats are pretty simply, the way you make them are by doing the class name which is float then the name then define it. Heres an example '''Objective-C
Int main { Float myFloat = 0.5; Float otherFloat = 1.1
Float answer = myFloat + otherFloat;
Return answer;
}
'''
So that's the basics, one of the best web sites in the world is ray wonderlich.com which is first on google, look it up there because theres great articles, besides that practice practice practice becuase you'll use them alot in your developer career.
Hope this helps, Kai.
Tyler Pflueger
8,089 PointsAs Kai Aldag says, you would able to use it his way.
Another way is by using NSNumber to create a float number NSNumber *number = [NSNumber numberWithFloat:4.1234]
Hopefully this is helpful.