Query about mod operator
Richard Gaskin
ambassador at fourthworld.com
Tue Apr 22 10:31:42 EDT 2008
There's a long-standing debate between engineers and people about
whether computers should be made to think like humans or the other way
around.
For microchip instruction sets I'll leave that debate to the pros in
that field, but with high-level languages like Transcript I tend to
favor people.
In a related discussion on the trunc function some time ago, I came up
with this more reliable alternative:
function logicalTrunc n
if n is not a number then return "NAN"
get offset(".", n)
if it > 0 then
delete char it to -1 of n
end if
return n
end logicalTrunc
....which Kay C. Lan made more efficient with:
function anotherLogicalTrunc n
if n is not a number then return "NAN"
set the itemDelimiter to "."
return item 1 of n
end anotherLogicalTrunc
Similarly, it seems we could do something like this for mod:
function logicalMod n
set the itemdel to "."
get item 2 of n
if it is empty then return 0
else return it
end logicalMod
Where would this fail?
And should we expect a high-level language to return results like this
from the engine directly, or is there some benefit to having illogical
byproducts of microchip design as our result that I'm not understanding?
--
Richard Gaskin
Managing Editor, revJournal
_______________________________________________________
Rev tips, tutorials and more: http://www.revJournal.com
More information about the use-livecode
mailing list