Sign in to follow this  
Followers 0
Garrett19212

Math Problem

16 posts in this topic

When I multply a number by 1 i get -1.#IND

How can i make it successfully multply it by 1.

Share this post


Link to post
Share on other sites



What do you mean 0/0

here is an example of what i am doing.

$var1 = $var1 * $var2

Var2 is a customizeable value, so lets say its 1 by default

Then i make a label display $var1

it will display -1.#IND

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Firstly, you can do this instead.

$var1 *= $var2

Secondly, what does $var1 start as?

$var1 = 2
$var2 = 1
$var1 *= $var2
msgbox(0,0,$var1)

This works fine for me.

*Edit: And what w0uter meant was did you divide by zero? (I guess he should have said #/0, # being any number) Anything divided by zero will give you the result you're getting. (Ooops, see correction#2)

*Correction: Upon testing, I notice that anything divided by zero returns "1.#INF"

I find -1.#IND in the helpfile under ACos, ASin, Log, and Mod.

Are you using any of these functions in your script?

*Correction#2: Er, uh.. nevermind, w0uter is right. 0/0 (zero divided by zero) will return -1.#IND. Anything ELSE divided by zero will return 1.#INF. My bad.

Edited by Saunders

Share this post


Link to post
Share on other sites

No im not dividing by 0, nor am I using any of those functions.

Share this post


Link to post
Share on other sites

Iv been testing it as $var1 = 5

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Also: Did you try my example? Does it work?

*Edit: What w0uter said, but you don't need to give us a 2 page script either. Just post a working example that gives you the error. And by working I mean one that you can copy and paste, add nothing to, and run and it will give you the same error. That way we can test the exact same thing.

Edited by Saunders

Share this post


Link to post
Share on other sites

Im trying to get the error on a new script but I cant seem to get it, I have a ton of things that may affect it in script that is giving that error. So I don't know which things to copy.

Share this post


Link to post
Share on other sites

In that case just post it as an attachment or the code itself (if its a relatively small script).


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

Here it is.

Its a script that calculates damage, and damage reduction for warcraft 3.

If you put 0 in armor points, you will get the error im talking about.

Push enter to calculate the result.

DamageCalculater1.zip

Share this post


Link to post
Share on other sites

Anything multiplied by 0 is 0.

$AttackR = $armorAm * 0.06
$AttackR2 = 1 + 0.06 * $armorAm

Share this post


Link to post
Share on other sites

Anything multiplied by 0 is 0.

$AttackR = $armorAm * 0.06
$AttackR2 = 1 + 0.06 * $armorAm
0.06 isn't 0.

Share this post


Link to post
Share on other sites

I never said it was.

Share this post


Link to post
Share on other sites

#16 ·  Posted (edited)

Division by zero:

$armorAm = GUICtrlRead($ArmorAmount) ; assume this is 0

...

$AttackR = $armorAm * 0.06 ; 0 * .06 = 0

$AttackR2 = 1 + (0.06 * $armorAm) ; 1 + .06 * 0 = 1

$AttackR = $AttackR / $AttackR2 ; $attackR = 0 / 1 = 0

$AttackAvg2 = $AttackR ; AttackAvg2 = 0

$AttackAvg2 = Round($AttackAvg2, 2) ; $AttackAvg2 = 0 (rounded)

$AttackAvg2 = $AttackAvg2 * 100 ; $AttackAvg2 = 0 * 100 = 0

$AttackAvg2 = $AttackAvg / $AttackAvg2 * 10

; $AttackAvg2 = $AttackAvg / 0 * 10 = ($AttackAvg / 0) * 10 !ERROR!

Since someone can (probably) have 0 armor points (if they're walking around naked, and aren't very hairy, I suppose), you will probably need to do an alternate calculation for that instance.

Edited by Jason_A

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0