Forcing string comparisons, or When is "0" not 0?

Mark Waddingham mark at livecode.com
Thu Oct 15 19:42:49 EDT 2015


I pondered 'is exactly' for the 'is really' semantics previously proposed which are the same as yours :)

However I do think that it is slightly misleading - when it comes to numbers (due to the inexact representation used) you can end up with two numeric tokens which are slightly different but compare with 'is exactly' true.

I'm wondering whether 'is strictly' is perhaps most appropriate as it suggests the two sides are equal under strict rules (type and value are the same) compared to loose rules (try number comparison first, then string).

Mark.

Sent from my iPhone

> On 15 Oct 2015, at 19:47, Geoff Canyon <gcanyon at gmail.com> wrote:
> 
>> On 2015-10-14 22:19, Devin Asay wrote:
>> 
>> Shouldn’t there be a way to force a string comparison? I know LC tries
>> to be all helpful about casting numerals as numbers, but what if I
>> want to know if it’s the exact string?
> 
> I think you have come up with the best syntax right there.
> 
> put 3 is "3" -- true
> put 3 is "3.0" -- true
> put 3 is 2.999999999999999 -- true
> 
> put 3 is exactly "3" -- false
> put 3 is exactly "3.0" -- false
> put "3" is exactly "3" -- true
> put 3 is exactly 3 -- true
> put 3 is exactly 3.0 -- true
> put 3 is exactly 2.999999999999999 -- false
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode




More information about the use-livecode mailing list