Sunset, sunrise, twilight calculations in LC?

William Prothero prothero at earthednet.org
Sat Aug 23 15:46:14 EDT 2014


Folks:
Try this:
You have to be sure that if myNum is a perfect negative integer, floor(myNum) = myInteger
while
floor(-some non-integer) = trunc(myNum - 1)

Colin’s version works too.

on mouseUp
   put 1.55 into tNum
   put 1 into tCor
   put "case: "&tNum&" Correct value: "&tCor&", Calc Value: "&floor(tNum)&cr into tResult
   put 0 into tNum
   put 0 into tCor
   put "case: "&tNum&" Correct value: "&tCor&", Calc Value: "&floor(tNum)&cr after tResult
   put -1.55 into tNum
   put -2 into tCor
   put "case: "&tNum&" Correct value: "&tCor&", Calc Value: "&floor(tNum)&cr after tResult
   put -1.25 into tNum
   put -2 into tCor
   put "case: "&tNum&" Correct value: "&tCor&", Calc Value: "&floor(tNum)&cr after tResult
   put -1 into tNum
   put -1 into tCor
   put "case: "&tNum&" Correct value: "&tCor&", Calc Value: "&floor(tNum)&cr after tResult
   put tResult into fld "myOutput"
end mouseUp

function floor mNum
   if tNum < 0 then
      if trunc(tNum) = tNum then
         return tNum
      else
         return trunc(tNum - 1)
      end if
   else
      return trunc(mNum)
   end if
end floor

Cheers,
Bill

On Aug 23, 2014, at 12:24 PM, Richmond <richmondmathewson at gmail.com> wrote:

> Go, get it Happy People :)
> 
> http://forums.livecode.com/viewtopic.php?f=5&t=21404
> 
> Richmond.
> 
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list