Hey everyone. I just started working on learning some Lua (as well as python) and had a few questions on the lua aspect. For a first program I was making a prime number finder sort of deal and realized I couldn't find that without in some way detecting decimals. Is there some equivilant fpart( or ipart( from ti basic in lua? Thanks!
The math.modf function returns both(separately).

http://lua-users.org/wiki/MathLibraryTutorial

Good luck learning! Smile
Okay, so say I want the decimal stored to var B and the integer into var A how would I do that since it returns two values? Oh wait.. Is it the same way that C returns values?
C does not support returning multiple values from a single function so no, it is not the same as C. If you want the integral part in a and the fractional part in b you can do so like this:

Code:
a, b = math.modf(math.pi)

In this case a is 3 and b is 0.14159 (etc)
Yeah lol. I found that out earlier today. But thanks for clarifying!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement