?

150 views
Skip to first unread message

fuzzy wozzy

unread,
May 7, 2016, 12:47:50 PM5/7/16
to Shen

(integer? (/ 77777777777777777 2))
true

Mark Tarver

unread,
May 7, 2016, 12:55:07 PM5/7/16
to Shen

The integer test in Shen runs in log time and is predicated on the following 'equations'


integer - integer = integer
non-integer - integer = non-integer


These 'equations', though mathematically true, can fail outside a certain range (commonly beyond 15 digits) which depends on the precision of the platform and therefore the accuracy of this test depends on the precision of the arithmetic. 


from http://www.shenlanguage.org/learn-shen/shendoc.htm#Numbers

Willi has a test beyond 10^15 whcih works I think.

Mark

fuzzy wozzy

unread,
May 8, 2016, 3:51:27 AM5/8/16
to Shen

(>= 3.00000000000000005 3.00000000000000006)
true

(> 3.00000000000000005 3.00000000000000006)
false

(< 3.00000000000000005 3.00000000000000006)
false

fuzzy wozzy

unread,
May 8, 2016, 3:51:27 AM5/8/16
to Shen

(integer? 1.00000000000000001234567)
true

(= 1.00000000000000000 1.00000000000000001)
true

(= 1.00000000000000001 1.0000000000000000234567)
true


Willi Riha

unread,
May 8, 2016, 5:19:06 PM5/8/16
to Shen

Willi Riha

unread,
May 8, 2016, 5:52:03 PM5/8/16
to Shen
Just a short comment!

I do have an integer test function, int?, which is functionally equivalent to Mark's built-in integer? predicate..
However, Mark's integer? runs in (log n) ^2 time, whilst mine is O(log n) time. For numbers < 2^32 there is 
not a significant time difference. For larger numbers, there is!.
Both Mark's, and my algorithm, are essentially based on the equation " (= (floor (abs X) (abs X))".
I respect that this is Mark's decision. After all, Shen is his language!





On Saturday, May 7, 2016 at 5:47:50 PM UTC+1, fuzzy wozzy wrote:

fuzzy wozzy

unread,
May 9, 2016, 6:36:25 AM5/9/16
to Shen

(= 12345678901234568999998999555.3 12345678901234569111111111111.3)
true

(= 12345678901234568999998999555.3 123456789012345691111111111111.3)
false

fuzzy wozzy

unread,
May 9, 2016, 6:36:25 AM5/9/16
to Shen

(= 12345678901234567 (* 1234567890123456.7 10))
false

(> 12345678901234567 (* 1234567890123456.7 10))
false

(< 12345678901234567 (* 1234567890123456.7 10))
true


Mark Tarver

unread,
May 9, 2016, 6:39:16 AM5/9/16
to Shen
Above 15 places you are subject to inaccuracies - Google floating point inaccuracy.   

Mark

Mark Tarver

unread,
May 12, 2016, 12:52:08 PM5/12/16
to Shen
Actually, up to 900 million million or some humungous number I can't even time the integer? test in Shen.  Above that the other arithmetic operations break down as fuzzy shows.  And really you can't dictate how other platforms will behave with numbers of this magnitude.  So really it's all a bit academic.  Prime number hunting has long exceeded these figures.

Mark

fuzzy wozzy

unread,
May 14, 2016, 12:58:31 PM5/14/16
to Shen

this seems counterintuitive,

(integer? 1.0)
true

(= 1 1.0) could be true valuewise, but it seems to be true typewise as well...

of course, if using list for numbers, precision could be extended to 100000 digits or more




fuzzy wozzy

unread,
May 21, 2016, 12:54:02 PM5/21/16
to Shen

in ruby,

235.223489123123982 > 235.223489123123981
false

235.223489123123982 < 235.223489123123981
false

235.223489123123982 == 235.223489123123981
true

just as I thought... most languages in use today are more than likely in the same predicament as shen repl
when it comes to floating point numbers, anyone who claims to be serious about floating point precision
who does not consider using shen list to achieve such precision is not being serious enough in my book.

fuzzy wozzy

unread,
May 21, 2016, 1:17:44 PM5/21/16
to Shen

fuzzy wozzy

unread,
May 21, 2016, 1:17:44 PM5/21/16
to Shen

the last line may have been a non sequitur of a sort, a mishap in copy/paste, if so, my bad...
Reply all
Reply to author
Forward
0 new messages