# How To Alter The Precision When Using Comparisons

10 replies to this topic

### #1 WarriorArtiste

WarriorArtiste

3d Creator

• New Member
• 1032 posts

Posted 07 February 2008 - 09:42 PM

How do you alter the precision for comparing numbers? There is only 1 function, and it only effects ds_lists.
• 0
Ultimate 3D 2.1 April 2, 2008!

-33% of the population are Zoogles, 34% of the population are Yoodles, and 100-(34+33)% of the population are noodles. If you put this in your signature, I'm alright with that, if not, that's fine too.

### #2 Tahnok

Tahnok

• GMC Member
• 1854 posts
• Version:GM:Studio

Posted 07 February 2008 - 09:47 PM

Do it manually. For example, here's check to see if x is within +-0.1 of the target value:

if(x >= targetValue - 0.1 && x <= targetValue + 0.1)

You could put something like this in a script easily enough.

Or, simply create a script to quickly load some values into a data structure, do the calculation, and then unload the numbers.
• 0

### #3 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 07 February 2008 - 09:56 PM

if(x >= targetValue - 0.1 && x <= targetValue + 0.1)

`if (abs(x - targetValue) <= 0.1)`

Is better.
• 0

### #4 WarriorArtiste

WarriorArtiste

3d Creator

• New Member
• 1032 posts

Posted 07 February 2008 - 10:08 PM

Parenthesis actually speed up the code?
• 0
Ultimate 3D 2.1 April 2, 2008!

-33% of the population are Zoogles, 34% of the population are Yoodles, and 100-(34+33)% of the population are noodles. If you put this in your signature, I'm alright with that, if not, that's fine too.

### #5 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 07 February 2008 - 10:44 PM

Parenthesis actually speed up the code?

<{POST_SNAPBACK}>

Because that's the only difference? Can you honestly not tell what I did differently?
• 0

### #6 WarriorArtiste

WarriorArtiste

3d Creator

• New Member
• 1032 posts

Posted 07 February 2008 - 11:13 PM

Parenthesis actually speed up the code?

<{POST_SNAPBACK}>

Because that's the only difference? Can you honestly not tell what I did differently?

<{POST_SNAPBACK}>

Actually, if you examined carefully, you would see that both your's and Tahnok's codes have the same amount of parenthesis, thus excluding your hypothesis that I could not tell what you did differently from having basis in reality.
• 0
Ultimate 3D 2.1 April 2, 2008!

-33% of the population are Zoogles, 34% of the population are Yoodles, and 100-(34+33)% of the population are noodles. If you put this in your signature, I'm alright with that, if not, that's fine too.

### #7 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 07 February 2008 - 11:42 PM

So now you can't read or count.
• 0

### #8 Tahnok

Tahnok

• GMC Member
• 1854 posts
• Version:GM:Studio

Posted 08 February 2008 - 08:41 AM

`if (abs(x - targetValue) <= 0.1)`

Is better.

<{POST_SNAPBACK}>

Good point, I'll keep that one in mind.
• 0

### #9 pedrosorio

pedrosorio

GMC Member

• GMC Member
• 971 posts

Posted 09 February 2008 - 12:10 AM

Parenthesis actually speed up the code?

<{POST_SNAPBACK}>

Because that's the only difference? Can you honestly not tell what I did differently?

<{POST_SNAPBACK}>

Actually, if you examined carefully, you would see that both your's and Tahnok's codes have the same amount of parenthesis, thus excluding your hypothesis that I could not tell what you did differently from having basis in reality.

<{POST_SNAPBACK}>

GMC is so hilarious sometimes...
• 0
"Let's leave the classics for your parents." - KC LC

### #10 WarriorArtiste

WarriorArtiste

3d Creator

• New Member
• 1032 posts

Posted 10 February 2008 - 02:11 PM

Well "Mr.SmartyPants" Yourself, I estimate that you are mathematically correct 99% of the time? Meaning that one learns to expect you to be completely correct without examining any sources. So, instead of replying with something like, "Woa, that totally is soooo is right!" I decided on an alternative; asking an honest question if parenthesis speed up the code because in my opinion, FUNCTION CALLS DID NOT SERVE AS PARENTHESIS IN THE GIVEN CONTEXT. Your rude, pithy response was completely unwarranted and came as a complete surprise. So lets pretend to forget this incident, and, based on your rudeness, we can assume that adding ONE pair of parenthesis surrounding an if "statement" does infact NOT speed up the game?

Edited by WarriorArtiste, 10 February 2008 - 02:14 PM.

• 0
Ultimate 3D 2.1 April 2, 2008!

-33% of the population are Zoogles, 34% of the population are Yoodles, and 100-(34+33)% of the population are noodles. If you put this in your signature, I'm alright with that, if not, that's fine too.

### #11 Yourself

Yourself

The Ultimate Pronoun

• GMC Elder
• 7352 posts
• Version:Unknown

Posted 10 February 2008 - 06:25 PM

Maybe next time you should start a new topic if you want to ask a question that has nothing to do with your current one instead of confusing me (and others) with a question that makes it look like you can't tell the difference between two pieces of code.

Anyway, this topic has its answer, there's no reason to leave it open.
• 0