Arin2010-04-16 00:36:05
So I've put this into Nexus:
Works until the variable cels is a negative number. Then it doesn't do the division.
Any ideas why?
CODE
#math celspro $1-32
#math oneeight 9/5
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
#math oneeight 9/5
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
Works until the variable cels is a negative number. Then it doesn't do the division.
Any ideas why?
Razenth2010-04-16 00:48:13
Maybe you need parenthesises? Iunno, don't use nexus.
Xenthos2010-04-16 01:11:46
QUOTE (Arin @ Apr 15 2010, 08:36 PM) <{POST_SNAPBACK}>
So I've put this into Nexus:
Works until the variable cels is a negative number. Then it doesn't do the division.
Any ideas why?
CODE
#math celspro $1-32
#math oneeight 9/5
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
#math oneeight 9/5
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
Works until the variable cels is a negative number. Then it doesn't do the division.
Any ideas why?
Why not have another variable that is a check on whether it is negative (something like it is 1 if positive, 0 if negative, or whatever kind of flag you want). Then just make sure that cels is multiplied by -1 if it is negative and the flag is set appropriately.
Remultiply by -1 after the division if the flag is set.
Doesn't explain why, but would give a way to work around it.
Arin2010-04-16 01:34:36
So how about this?
#math celspro $1-32
#math oneeight 9/5
#IF $celspro < 0 {
#math celspro $celspro * -1
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
} else {
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
}
Lemme give it a shot, after learning and let you know results
#math celspro $1-32
#math oneeight 9/5
#IF $celspro < 0 {
#math celspro $celspro * -1
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
} else {
#math cels $celspro/$oneeight
#ECHO_ In real temperature, it is now $cels C.
}
Lemme give it a shot, after learning and let you know results
Xavius2010-04-16 01:48:02
The most likely reason it doesn't work is that Nexus is interpreting the negative sign as a non-numeric character. Hard to say without seeing your trigger lines or pushing a few debug echos into the script.
Also, why set a variable for 1.8? And are you sure that $oneeight is actually 1.8 and not 1? (Honest question there, don't use Nexus.)
EDIT: And looking over your script, I can guarantee that that won't fix the problem. Here's hoping you catch this before trying and beating your head on your desk.
EDITEDIT:
Ok, so, quicker for me to go check than wait for you to go check.
Trigger: You feel the temperature around you to be about {d} F.
#math cels ($1 - 32) * 5 / 9
#echo $cels
Trigger: You feel the temperature around you to be about -{d} F.
#math cels ($1 - 32) * -5 / 9
#echo $cels
Now I need to go wash the Nexus off my hands.
Also, why set a variable for 1.8? And are you sure that $oneeight is actually 1.8 and not 1? (Honest question there, don't use Nexus.)
EDIT: And looking over your script, I can guarantee that that won't fix the problem. Here's hoping you catch this before trying and beating your head on your desk.
EDITEDIT:
Ok, so, quicker for me to go check than wait for you to go check.
Trigger: You feel the temperature around you to be about {d} F.
#math cels ($1 - 32) * 5 / 9
#echo $cels
Trigger: You feel the temperature around you to be about -{d} F.
#math cels ($1 - 32) * -5 / 9
#echo $cels
Now I need to go wash the Nexus off my hands.
Arin2010-04-16 02:17:51
because I tried dividing by 1.8 and it didn't work...
so now I have to do it manually
so now I have to do it manually
Arin2010-04-16 02:22:08
Problem is when it is 0F
Xavius2010-04-16 02:26:47
Veyrzhul2010-04-16 07:50:16
I don't think I've ever used #math. You should just be able to #set celciustemp = (($fahrenheittemp - 32) / 1.8) , although it's been a while since I had to do that, so the syntax might be slightly wrong.