Page 1 of 1

getting decimal numbers

Posted: Tue Mar 22, 2011 7:45 pm
by caj
I have search and got plenty of info but no examples in how to go about showing a decimal. Ive tried the ${Float.Centi} line w/o any luck. Any hint/advice/link to what im doing wrong.

heres what i have so far.

Code: Select all

#event tmr "#*#This zone has been running for #1#:#2#:#3#:#4#"

Sub Main
/uptime
/delay 2s
/doevents
/end


sub event_tmr(int,Dys,Hrs,Mns)
  /declare tday int outer
  /echo ${Dys} : ${Hrs} : ${Mns}
  /varcalc tday ${Float[${Math.Calc[${Dys}/24]}+${Hrs}*.05].Centi}
  /echo ${tday}
/end
if i take the ${Float.Centi} away i get a number w/o the .00 with the float.centi I just get a 0(zero) return. Im starting to believe its not possible to return a number in decimals or at least wont /echo it back. I dunno. im quite baffled atm.

(hell i will even read through a flame as long as it gives me an idea what im trying to accomplish)

Re: getting decimal numbers

Posted: Tue Mar 22, 2011 8:22 pm
by htw
caj wrote:I have search and got plenty of info but no examples in how to go about showing a decimal. Ive tried the ${Float.Centi} line w/o any luck. Any hint/advice/link to what im doing wrong.

heres what i have so far.

Code: Select all

#event tmr "#*#This zone has been running for #1#:#2#:#3#:#4#"

Sub Main
/uptime
/delay 2s
/doevents
/end


sub event_tmr(int,Dys,Hrs,Mns)
  /declare tday int outer
  /echo ${Dys} : ${Hrs} : ${Mns}
  /varcalc tday ${Float[${Math.Calc[${Dys}/24]}+${Hrs}*.05].Centi}
  /echo ${tday}
/end
if i take the ${Float.Centi} away i get a number w/o the .00 with the float.centi I just get a 0(zero) return. Im starting to believe its not possible to return a number in decimals or at least wont /echo it back. I dunno. im quite baffled atm.

(hell i will even read through a flame as long as it gives me an idea what im trying to accomplish)

If you want float output, don't you want to declare it as a float, and not an int?

-> /declare tday int outer
-> /declare tday float outer

Re: getting decimal numbers

Posted: Tue Mar 22, 2011 8:25 pm
by caj
had an "aha" moment after looking at other macros i finally found it.

changed

Code: Select all

 /declare tday int outer
to

Code: Select all

 /declare tday float
simple as hell. spent all day and just couldnt figure it out until after i ask for help go figure. sorry for the wasted thread.

Re: getting decimal numbers

Posted: Tue Mar 22, 2011 10:58 pm
by caj
not sure why i posted help here, must be the cold medicine ive been takeing. this should have been in the vip area. but anyway thank you htw for the quick reply. I did figure out the solution about the same time you posted and as you can see its almost the same solution. I will post the result what i was trying to do on vip.