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.)
<climits> Equivalent?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: <climits> Equivalent?
Isn't max() and min() what you want? you can use both of them like max(100min(20)) or something like that 

Knowledge is meant to be shared.
Re: <climits> Equivalent?
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?
Re: <climits> Equivalent?
What do you intend for 999 trillion? 10^13 or 10^19 ??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.)
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
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w