Sunset, sunrise, twilight calculations in LC?
Richmond
richmondmathewson at gmail.com
Sat Aug 23 15:13:49 EDT 2014
On 23/08/14 22:03, J. Landman Gay wrote:
> On 8/23/2014, 1:28 PM, Richmond wrote:
>> On 23/08/14 21:13, Charles E Buchwald wrote:
>>> So I'm thinking...
>>>
>>> function Floor pValue
>>> if pValue < 0 then return trunc(pValue) - 1
>>> else return trunc(pValue)
>>> end Floor
>>
>> Quite unnecessary when 'round' does the trick without
>> any homegrown functions.
>
>
> Nope. The floor of -2.2 is -3. The round is -2.
>
> Charles' function works except for negative integers. I think it needs
> to check for that.
>
Well, presumably one way to do this would be to check if the number is
positive or negative,
and then, if it is negative multiply it by -1, round it, and then
multiply it by -1 again.
I just set up a stack with 2 fields; "NUMB" and "RN"
and a button "FLOOR" containing this script:
on mouseUp
put fld "numb" into NUMB
if NUMB = 0 then
---nix
else
if NUMB < 0 then
put (NUMB * (-1)) into NUMB
put round(NUMB) into RN1
put (RN1 *(-1)) into RN2
put RN2 into fld "RN"
else
put round(NUMB) into fld "RN"
end if
end if
end mouseUp
Magic.
Richmond.
More information about the use-livecode
mailing list