A very strange equality

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
livo
Posts: 2
Joined: Fri Oct 27, 2006 1:06 pm

A very strange equality

Post by livo » Thu Oct 08, 2009 4:56 pm

I'm probably not in the right forum place (sorry), but if I type in the message box :

Code: Select all

put  "0e363579" = "0e511970"
on my (Mac snow leopard) machine, the answer is "true".

Is there any - very strange - reason for that kind of mathematical miracle ?

Livo :-)
Last edited by livo on Thu Oct 08, 2009 10:16 pm, edited 2 times in total.

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4163
Joined: Sun Jan 07, 2007 9:12 pm

Post by bn » Thu Oct 08, 2009 6:36 pm

livo,

isn't 0 to the power of any number = 0?
That would explain why Rev returns true.
put "1e10" = "1e11"
returns false, apparently Rev evaluates the string and thinks it is a number and 0 equals 0
But I am on treacherous grounds here, math does not like me...

regards
Bernd

mwieder
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3581
Joined: Mon Jan 22, 2007 7:36 am
Contact:

Post by mwieder » Thu Oct 08, 2009 10:17 pm

Right (on both counts: this isn't the right place to post this, and rev is evaluating the inputs as math).

If you're needing to see if two hex strings are the same value (that's my guess based on the two strings) then try prefacing them with some character that can't be evaluated as a hex digit. For example,

put "x" & "0e363579" = "x" & "0e511970"

livo
Posts: 2
Joined: Fri Oct 27, 2006 1:06 pm

Post by livo » Thu Oct 08, 2009 10:55 pm

Thank you both for this analysis, but this had nothing to do with any hex comparison (BTW will introduce some trouble with any hex value beginning wit "0E******")

I just wonder and try to understand WHY rev evaluates a simple ascii string as a mathematical exponentiation, and not with any of the other operators like {put "3+3" = "2*3"} or {put "0^8" = "0^88"}...

Anything with a number & "e" is evaluated as a number... and not as an alphanumerical string.

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Thu Oct 08, 2009 11:30 pm

I just wonder and try to understand WHY...
Because that's how xTalk languages work. Just get used to it. You will learn to appreciate it, I'm sure.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Sat Oct 10, 2009 2:32 am

My guess is that 0e36758 is a interpreted as a number, while "3*3" is an expression.

Best,

Mark Smith

Post Reply