<climits> Equivalent?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
hwbehrens
Posts: 19
Joined: Fri Mar 19, 2010 9:10 pm

<climits> Equivalent?

Post by hwbehrens » Thu Jun 25, 2015 6:03 pm

I recently had the need for both INT_MAX and INT_MIN in Livecode - what solutions are you guys using to accomplish this behavior?

I need to be able to reliably run mathematical operations (min, max, comparators, etc) on pairs of numbers, and when numbers get too large, you start to get very strange behavior. I suppose I could hard-code the values of -999 trillion and 999 trillion, which seem to be a functional limit based on 60 seconds of testing in the message box, but I'd prefer to use a more reliable, version-agnostic method if possible. Any ideas?

(For reference, I'd like to use it to do unified set evaluations in a math library; i.e. tVar < 0 could be thought of as testing whether tVar is in the set (INT_MIN,0), while -5 < tVar <= 0 could be represented as (-5,0] and so on. However, without a reliable way of representing INT_MIN and INT_MAX, single-sided ranges aren't very well-defined sets.)

zaxos
Posts: 222
Joined: Thu May 23, 2013 11:15 pm

Re: <climits> Equivalent?

Post by zaxos » Wed Jul 01, 2015 11:47 pm

Isn't max() and min() what you want? you can use both of them like max(100min(20)) or something like that :P
Knowledge is meant to be shared.

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: <climits> Equivalent?

Post by SparkOut » Thu Jul 02, 2015 7:32 am

I think Hans is already familiar with max() and min() but instead trying to determine the computational limit of an integer representation. ie if tVar > 0 then we know it is greater than zero, but we also know that, unlike the implication of the comparison, it is also less than another, unknown, value beyond which a calculation involving tVar would return inconsistent results. I think. Is your question asking for that unknown value Hans?

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: <climits> Equivalent?

Post by MaxV » Mon Dec 19, 2016 5:19 pm

hwbehrens wrote:I recently had the need for both INT_MAX and INT_MIN in Livecode - what solutions are you guys using to accomplish this behavior?

I need to be able to reliably run mathematical operations (min, max, comparators, etc) on pairs of numbers, and when numbers get too large, you start to get very strange behavior. I suppose I could hard-code the values of -999 trillion and 999 trillion, which seem to be a functional limit based on 60 seconds of testing in the message box, but I'd prefer to use a more reliable, version-agnostic method if possible. Any ideas?

(For reference, I'd like to use it to do unified set evaluations in a math library; i.e. tVar < 0 could be thought of as testing whether tVar is in the set (INT_MIN,0), while -5 < tVar <= 0 could be represented as (-5,0] and so on. However, without a reliable way of representing INT_MIN and INT_MAX, single-sided ranges aren't very well-defined sets.)
What do you intend for 999 trillion? 10^13 or 10^19 ??
Because the max reliable direct mathematical operation on number with 64bit computer is around 10^19, over 10^19 you have to create special functions.
I made this job once upon a time, in order to work with number long any size.
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply