Troubles with inequality

Graham Samuel livfoss at
Sat Feb 7 04:47:25 EST 2015

Thanks - I don’t completely understand this as an economical solution, but I think what you’re saying is that any number, even stored in a variable, can be treated as a string - then things can be compared character by character. This is almost the solution I adopted, but I used fields since they stay as strings from the off.


> On 7 Feb 2015, at 02:38, Kay C Lan <lan.kc.macmail at> wrote:
> On Thu, Feb 5, 2015 at 7:02 AM, Graham Samuel <livfoss at> wrote:
>> Thanks Jacque, a gold mine of information as usual. But it’s pretty
>> obscure, isn’t it? All this started for me because I wanted to test if two
>> numbers were equal, knowing that they probably weren’t exactly equal to the
>> last decimal place but nevertheless were ‘engineering equal’ as it were -
>> say to six places of decimals. So I tried to truncate them to that length
>> and then compare them. More fool me. But now I think I know what should be
>> done, thanks to you - and to everyone else who replied.
>> Graham
> Why not a simple: (in the multline msg box)
> put "1.99999999901" into a
> put "1.99999999902" into b
> put a = b  into msg
> put cr & (char 1 to 8 of a = char 1 to 8 of b) after msg
> put "1.0" into a
> put "1.0000000001" into b
> put cr & (a = b) after msg
> put cr & (char 1 to 8 of a = char 1 to 8 of b) after msg
> 8 characters is to 6 decimal places and the fact that LC automatically
> casts to numbers where it can nicely solves the problem that although
> string 1.0 <> 1.000000 in your case you are interested in the numeric value
> so you get the correct answer.
> LCs chunking capabilities are brilliant, we sometimes just need to remember
> that a number is a word in LC, and words have characters, and characters
> can be compared. The nice thing about LC is when presented with a number
> Cat you don't have to skin it with only number solutions; you can engineer
> any result you want ;-)
> _______________________________________________
> use-livecode mailing list
> use-livecode at
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:

More information about the Use-livecode mailing list