I would like to append this to what may be a record number of incorrect scripts
on my part. Hugh pointed out in the forums that the floor of 5 is 5, and the
ceiling of -5 is -5. These scripts might actually be correct, but I'm not
guaranteeing anything at this point... My apologies for the noise
My apologies... I tested this when I first wrote it, and I thought I had
everything covered. As others have pointed out, it requires a test for negative
integers, so it should be:
function Floor pValue
if pValue is an integer OR pValue < 0 then return trunc(pValue) - 1
else return trunc(pV
Beware:
This function fails when the number is a negative integer.
Bill
> function Floor pValue
> if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue)
> end Floor
William Prothero
http://es.earthednet.org
> On Aug 27, 2014, at 9:11 AM, Bob Sneidar wrote:
>
> Nicely done! I lov
I’ve always thought that LC should include a roundUp and roundDown version of
round().
Bob S
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http:
Nicely done! I love this list!!
Bob S
On Aug 23, 2014, at 13:22 , Charles E Buchwald
mailto:char...@buchwald.ca>> wrote:
function Floor pValue
if pValue < 0 then return trunc(pValue) - 1 else return trunc(pValue)
end Floor
I know this is trivial, but here's a ceiling function, just to kind o
Just what I was thinking.
Bob S
On Aug 23, 2014, at 12:13 , Richmond
mailto:richmondmathew...@gmail.com>> wrote:
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 ag
Yer a bit low. I’d add a pint.
Bob
On Aug 23, 2014, at 11:29 , Richmond
mailto:richmondmathew...@gmail.com>> wrote:
No: I was running 2 pints of beer :)
Richmond.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to
floor = roundDown?
Bob
On Aug 23, 2014, at 09:13 , Earthednet-wp wrote:
> Richmond,
> Floor of a number is the largest integer that is less than or equal to the
> number. For positive numbers, it would be trunc(myNumber) but for negative
> numbers, floor(-4.34) would have to evaluate to -5.
Not to throw a wrench in the works, but wasn’t there some discussion in the
past about different versions of Julian dates? Which one is the more widely
accepted? I suppose the question could be formed, which one does Microsoft use
for Excel? :-)
Bob S
On Aug 23, 2014, at 13:27 , Mark Wieder
Hey thanks for that Kay. I have a date conversion function that includes
formats like sqlDate which the LC covert command does not support. This will be
a nice addition.
Bob S
On Aug 23, 2014, at 01:28 , Kay C Lan
mailto:lan.kc.macm...@gmail.com>> wrote:
Nope, but this will help you calculat
Charles:
Your function misses a special case. If the negative number is an integer, you
wouldn’t want to subtract 1 from trunc(theNegativeNumber).
Best,
Bill
On Aug 23, 2014, at 1:22 PM, Charles E Buchwald wrote:
> Jacquie, I tested my script before I posted it, and it works for negative
> inte
On 8/23/2014, 3:25 PM, Mark Wieder wrote:
The script implementations are fine, but it was way too easy to add
these to the engine, so I just submitted a pull request for floor()
and ceil().
Good on you. :) I've sometimes wondered why those two weren't in the
engine, they're common in other lan
Charles-
Saturday, August 23, 2014, 11:21:44 AM, you wrote:
> Thanks. I have been using Sarah Reichelt's Date & Time Library,
> which contains these functions by Mark Wieder. I actually didn't
> realize they were under copyright, but I see that now.
I didn't either. Or more probably I'd forgotte
Awesome, Mark. Even better than a feature request!
On 23 Aug 2014, at 3:25 PM, Mark Wieder wrote:
> All-
>
> The script implementations are fine, but it was way too easy to add
> these to the engine, so I just submitted a pull request for floor()
> and ceil().
>
> --
> -Mark Wieder
> ahsoftw.
All-
The script implementations are fine, but it was way too easy to add
these to the engine, so I just submitted a pull request for floor()
and ceil().
--
-Mark Wieder
ahsoftw...@gmail.com
This communication may be unlawfully collected and stored by the National
Security Agency (NSA) in secr
Jacquie, I tested my script before I posted it, and it works for negative
integers.
Colin, just for fun, I've consolidated mine to one line.
Richmond, maybe you'd like to add "ceiling" to your sample stack?
function Floor pValue
if pValue < 0 then return trunc(pValue) - 1 else return trunc(pVal
Many languages equate booleans to 0 or 1. If LiveCode worked that way you could
say:
put trunk(n-(n<0))
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferen
> I found this link. It might be easier to convert this code to LC.
> http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
> Bill
>
> William Prothero
> http://es.earthednet.org
These algorithms have now been superceded by the NOAA algorithms
http://www.esrl.noaa.gov/gmd/grad/solcalc. There
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:
Go, get it Happy People :)
http://forums.livecode.com/viewtopic.php?f=5&t=21404
Richmond.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription
preferences:
http://lis
You could do it in one line:
put trunc(-14.2+10)-10
where the 10 part is a number bigger than anything you’re going to
encounter in your app.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to s
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 th
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.
On 23/08/14 21:19, Colin Holgate wrote:
You must be running LiveCode version -7. It shows -10 for me.
On Aug 23, 2014, at 2:05 PM, Richmond wrote:
put round(-9.8_
give us 10
Yo!
Richmond.
No: I was running 2 pints of beer :)
Richmond.
___
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.
Richmond.
___
Kay,
Thanks. I have been using Sarah Reichelt's Date & Time Library, which contains
these functions by Mark Wieder. I actually didn't realize they were under
copyright, but I see that now.
It says something nice about LC that this code is 10 years old and still valid
and valuable.
- Charles
--
You must be running LiveCode version -7. It shows -10 for me.
On Aug 23, 2014, at 2:05 PM, Richmond wrote:
> put round(-9.8_
>
> give us 10
>
> Yo!
>
> Richmond.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to
So I'm thinking...
function Floor pValue
if pValue < 0 then return trunc(pValue) - 1
else return trunc(pValue)
end Floor
On 23 Aug 2014, at 1:05 PM, Richmond wrote:
> On 23/08/14 20:44, J. Landman Gay wrote:
>> On 8/23/2014, 11:20 AM, Richmond wrote:
>>> That "floored me" :) Thanks for t
On 23/08/14 20:44, J. Landman Gay wrote:
On 8/23/2014, 11:20 AM, Richmond wrote:
That "floored me" :) Thanks for the heads up!
I just wrote this in the Message Box:
put trunc(-9.8)
and got '-9'
The correct answer for "floor" would be -10. It's the largest integer
that is less than the tes
On 8/23/2014, 11:20 AM, Richmond wrote:
That "floored me" :) Thanks for the heads up!
I just wrote this in the Message Box:
put trunc(-9.8)
and got '-9'
The correct answer for "floor" would be -10. It's the largest integer
that is less than the test number.
--
Jacqueline Landman Gay
On 23/08/14 19:13, Earthednet-wp wrote:
Richmond,
Floor of a number is the largest integer that is less than or equal to the
number. For positive numbers, it would be trunc(myNumber) but for negative
numbers, floor(-4.34) would have to evaluate to -5. Probably trunc(myNum-1)
would almost do it
Richmond,
Floor of a number is the largest integer that is less than or equal to the
number. For positive numbers, it would be trunc(myNumber) but for negative
numbers, floor(-4.34) would have to evaluate to -5. Probably trunc(myNum-1)
would almost do it, but I'm not in LC to check all cases, e.
On 23/08/14 17:44, Earthednet-wp wrote:
I found this link. It might be easier to convert this code to LC.
http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
Bill
William Prothero
http://es.earthednet.org
That looks very good indeed: but I don't understand what 'floor' means.
Richmond
I found this link. It might be easier to convert this code to LC.
http://williams.best.vwh.net/sunrise_sunset_algorithm.htm
Bill
William Prothero
http://es.earthednet.org
> On Aug 23, 2014, at 5:17 AM, Richmond wrote:
>
>> On 23/08/14 15:13, FlexibleLearning.com wrote:
>> Yes. I have done this.
On 23/08/14 15:13, FlexibleLearning.com wrote:
Yes. I have done this. It is not a trivial exercise. It requires a lot of
complex solar geometry calculations as well as Julian calcs.
Go to http://www.esrl.noaa.gov/gmd/grad/solcalc, pick the "Solar
Calculator", extract the javascript in the web pa
Yes. I have done this. It is not a trivial exercise. It requires a lot of
complex solar geometry calculations as well as Julian calcs.
Go to http://www.esrl.noaa.gov/gmd/grad/solcalc, pick the "Solar
Calculator", extract the javascript in the web page, then translate it to LC
for use in your own w
Nope, but this will help you calculate the Julian Date Number, which
you'll need:
put the date into tDate
convert tDate from date to dateItems
if ((item 2 of tDate = 1) or (item 2 of tDate = 2)) then
put 1 into tDay
else
put 0 into tDay
end if
put item 1 of tDate + 4
just for the
thrill, well
Craig Newman
-Original Message-
From: Charles E Buchwald
To: How to use LiveCode
Sent: Fri, Aug 22, 2014 7:46 pm
Subject: Sunset, sunrise, twilight calculations in LC?
Hi List People,
Does anyone know of an LC version of sunrise/sunset and twi
Hi List People,
Does anyone know of an LC version of sunrise/sunset and twilight calculations?
I found a couple of web based APIs, but I'd like it to work offline.
I found this: http://en.wikipedia.org/wiki/Sunrise_equation ... but it's going
to take me a while to translate that into LC, which is
39 matches
Mail list logo