
-----------------------------------
Diablo117
Tue Jul 07, 2009 8:13 pm

Checking if the result is a natural number
-----------------------------------
What is it you are trying to achieve?
After dividing a number, I want to see if it really IS divisible by finding out if the number outputted was natural, or decimal

What is the problem you are having?
Don't know if turing can do that or not

Please specify what version of Turing you are using
4.0.5

-----------------------------------
syntax_error
Tue Jul 07, 2009 8:32 pm

RE:Checking if the result is a natural number
-----------------------------------
look up, the term mod.

That should be more then enough for you.

And, yes it can.

-----------------------------------
Diablo117
Wed Jul 08, 2009 1:45 am

Re: Checking if the result is a natural number
-----------------------------------
wow, I feel as if I've been hit over the hit with an unusually large club for me not even thinkin of using mod in that way...lol

-----------------------------------
saltpro15
Wed Jul 08, 2009 9:48 am

RE:Checking if the result is a natural number
-----------------------------------

if num mod 2 = 0 
then
...
end if


-----------------------------------
apomb
Wed Jul 08, 2009 12:17 pm

Re: RE:Checking if the result is a natural number
-----------------------------------

if num mod 2 = 0 
then
...
end if


wouldnt that just check if the number is even?

-----------------------------------
DtY
Wed Jul 08, 2009 12:51 pm

Re: RE:Checking if the result is a natural number
-----------------------------------

if num mod 2 = 0 
then
...
end if


wouldnt that just check if the number is even?
num mod 2 would test if it's divisible by two. You'd replace two with whatever number you need to check if you can divide by.

-----------------------------------
Insectoid
Wed Jul 08, 2009 1:41 pm

RE:Checking if the result is a natural number
-----------------------------------
Another way,,

[code]
if num div X = num/X then
   ...
end if
[/code]

-----------------------------------
DtY
Wed Jul 08, 2009 9:06 pm

Re: RE:Checking if the result is a natural number
-----------------------------------
Another way,,


Although that method is slower and makes less sense..

-----------------------------------
saltpro15
Wed Jul 08, 2009 9:39 pm

RE:Checking if the result is a natural number
-----------------------------------
:oops:  thanks for correcting that guys

-----------------------------------
Zren
Wed Jul 08, 2009 11:03 pm

Re: Checking if the result is a natural number
-----------------------------------
I like my method.

if num = floor(num) then
put "Integer"
else
put "Real Number"
end if

-----------------------------------
syntax_error
Wed Jul 08, 2009 11:35 pm

Re: Checking if the result is a natural number
-----------------------------------
I like my method.

if num = floor(num) then
put "Integer"
else
put "Real Number"
end if

Hmm, seems like the smallest amount of code to me, nice.
