Computer Science Canada Checking if the result is a natural number |
Author: | Diablo117 [ Tue Jul 07, 2009 8:13 pm ] |
Post subject: | 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 |
Author: | syntax_error [ Tue Jul 07, 2009 8:32 pm ] |
Post subject: | 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. |
Author: | Diablo117 [ Wed Jul 08, 2009 1:45 am ] |
Post subject: | 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 |
Author: | saltpro15 [ Wed Jul 08, 2009 9:48 am ] | ||
Post subject: | RE:Checking if the result is a natural number | ||
|
Author: | apomb [ Wed Jul 08, 2009 12:17 pm ] | ||
Post subject: | Re: RE:Checking if the result is a natural number | ||
saltpro15 @ Wed Jul 08, 2009 9:48 am wrote:
wouldnt that just check if the number is even? |
Author: | DtY [ Wed Jul 08, 2009 12:51 pm ] | ||
Post subject: | Re: RE:Checking if the result is a natural number | ||
apomb @ Wed Jul 08, 2009 12:17 pm wrote: saltpro15 @ Wed Jul 08, 2009 9:48 am wrote:
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. |
Author: | Insectoid [ Wed Jul 08, 2009 1:41 pm ] | ||
Post subject: | RE:Checking if the result is a natural number | ||
Another way,,
|
Author: | DtY [ Wed Jul 08, 2009 9:06 pm ] | ||
Post subject: | Re: RE:Checking if the result is a natural number | ||
insectoid @ Wed Jul 08, 2009 1:41 pm wrote: Another way,,
Although that method is slower and makes less sense.. |
Author: | saltpro15 [ Wed Jul 08, 2009 9:39 pm ] |
Post subject: | RE:Checking if the result is a natural number |
thanks for correcting that guys |
Author: | Zren [ Wed Jul 08, 2009 11:03 pm ] | ||
Post subject: | Re: Checking if the result is a natural number | ||
I like my method.
|
Author: | syntax_error [ Wed Jul 08, 2009 11:35 pm ] |
Post subject: | Re: Checking if the result is a natural number |
Zren @ Wed Jul 08, 2009 11:03 pm wrote:
Hmm, seems like the smallest amount of code to me, nice. |