Remove >integer word, clean up some math code
parent
e35e99e575
commit
14a1c0905f
|
@ -1,9 +1,10 @@
|
||||||
- crypto sig11
|
- %allot-bignum-signed-2 is broken on both platforms
|
||||||
|
- sometimes fep when closing window
|
||||||
|
- windows rollover broken again
|
||||||
|
|
||||||
+ ui:
|
+ ui:
|
||||||
|
|
||||||
- sometimes fep when closing window
|
- dataflow view of [ { array } declare first ] is wrong
|
||||||
- windows rollover broken again
|
|
||||||
- docs: don't pass volatile aliens to callbacks
|
- docs: don't pass volatile aliens to callbacks
|
||||||
- live search: timer delay would be nice
|
- live search: timer delay would be nice
|
||||||
- menu should stay up if mouse button released
|
- menu should stay up if mouse button released
|
||||||
|
@ -41,7 +42,9 @@
|
||||||
|
|
||||||
+ compiler/ffi:
|
+ compiler/ffi:
|
||||||
|
|
||||||
- %allot-bignum-signed-2 is broken on both platforms
|
- optimization: if one branch throws an error, then we need to infer
|
||||||
|
types based solely on the other branch
|
||||||
|
- cross-word type inference
|
||||||
- callback scheduling issue
|
- callback scheduling issue
|
||||||
- amd64 structs-by-value bug
|
- amd64 structs-by-value bug
|
||||||
- intrinsic fixnum>float float>fixnum fixnum>bignum bignum>fixnum
|
- intrinsic fixnum>float float>fixnum fixnum>bignum bignum>fixnum
|
||||||
|
|
|
@ -26,7 +26,3 @@ IN: math
|
||||||
|
|
||||||
: most-positive-fixnum ( -- n ) first-bignum 1- ;
|
: most-positive-fixnum ( -- n ) first-bignum 1- ;
|
||||||
: most-negative-fixnum ( -- n ) first-bignum neg ;
|
: most-negative-fixnum ( -- n ) first-bignum neg ;
|
||||||
|
|
||||||
M: float >integer
|
|
||||||
dup most-negative-fixnum most-positive-fixnum between?
|
|
||||||
[ >fixnum ] [ >bignum ] if ;
|
|
||||||
|
|
|
@ -18,7 +18,8 @@ M: real hashcode >fixnum ;
|
||||||
M: real <=> - ;
|
M: real <=> - ;
|
||||||
|
|
||||||
: fp-nan? ( float -- ? )
|
: fp-nan? ( float -- ? )
|
||||||
double>bits -51 shift BIN: 111111111111 [ bitand ] keep = ;
|
double>bits -51 shift BIN: 111111111111 [ bitand ] keep
|
||||||
|
number= ;
|
||||||
|
|
||||||
M: float zero?
|
M: float zero?
|
||||||
dup 0.0 float= swap -0.0 float= or ;
|
dup 0.0 float= swap -0.0 float= or ;
|
||||||
|
|
|
@ -6,9 +6,9 @@ sequences-internals ;
|
||||||
|
|
||||||
UNION: integer fixnum bignum ;
|
UNION: integer fixnum bignum ;
|
||||||
|
|
||||||
: even? ( n -- ? ) 1 bitand 0 = ;
|
: even? ( n -- ? ) 1 bitand zero? ;
|
||||||
|
|
||||||
: odd? ( n -- ? ) 1 bitand 1 = ;
|
: odd? ( n -- ? ) 1 bitand 1 number= ;
|
||||||
|
|
||||||
: (gcd) ( b a y x -- a d )
|
: (gcd) ( b a y x -- a d )
|
||||||
dup zero? [
|
dup zero? [
|
||||||
|
@ -17,7 +17,8 @@ UNION: integer fixnum bignum ;
|
||||||
tuck /mod >r pick * swap >r swapd - r> r> (gcd)
|
tuck /mod >r pick * swap >r swapd - r> r> (gcd)
|
||||||
] if ; inline
|
] if ; inline
|
||||||
|
|
||||||
: gcd ( x y -- a d ) 0 1 2swap (gcd) abs ; foldable
|
: gcd ( x y -- a d )
|
||||||
|
0 1 2swap (gcd) dup 0 < [ neg ] when ; foldable
|
||||||
|
|
||||||
: (next-power-of-2) ( i n -- n )
|
: (next-power-of-2) ( i n -- n )
|
||||||
2dup >= [
|
2dup >= [
|
||||||
|
@ -52,8 +53,6 @@ M: integer /
|
||||||
2dup gcd nip tuck /i >r /i r> fraction>
|
2dup gcd nip tuck /i >r /i r> fraction>
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: integer >integer ;
|
|
||||||
|
|
||||||
M: fixnum >fixnum ;
|
M: fixnum >fixnum ;
|
||||||
M: fixnum >bignum fixnum>bignum ;
|
M: fixnum >bignum fixnum>bignum ;
|
||||||
M: fixnum >float fixnum>float ;
|
M: fixnum >float fixnum>float ;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
IN: math
|
IN: math
|
||||||
USING: errors generic kernel math-internals ;
|
USING: errors generic kernel math-internals ;
|
||||||
|
|
||||||
GENERIC: >integer ( x -- y ) foldable
|
|
||||||
GENERIC: >fixnum ( x -- y ) foldable
|
GENERIC: >fixnum ( x -- y ) foldable
|
||||||
GENERIC: >bignum ( x -- y ) foldable
|
GENERIC: >bignum ( x -- y ) foldable
|
||||||
GENERIC: >float ( x -- y ) foldable
|
GENERIC: >float ( x -- y ) foldable
|
||||||
|
|
|
@ -45,7 +45,7 @@ M: integer (^)
|
||||||
|
|
||||||
: power-of-2? ( n -- ? )
|
: power-of-2? ( n -- ? )
|
||||||
dup 0 > [
|
dup 0 > [
|
||||||
dup dup neg bitand =
|
dup dup neg bitand number=
|
||||||
] [
|
] [
|
||||||
drop f
|
drop f
|
||||||
] if ; foldable
|
] if ; foldable
|
||||||
|
@ -53,6 +53,6 @@ M: integer (^)
|
||||||
: log2 ( n -- b )
|
: log2 ( n -- b )
|
||||||
{
|
{
|
||||||
{ [ dup 0 <= ] [ "log2 expects positive inputs" throw ] }
|
{ [ dup 0 <= ] [ "log2 expects positive inputs" throw ] }
|
||||||
{ [ dup 1 = ] [ drop 0 ] }
|
{ [ dup 1 number= ] [ drop 0 ] }
|
||||||
{ [ t ] [ -1 shift log2 1+ ] }
|
{ [ t ] [ -1 shift log2 1+ ] }
|
||||||
} cond ; foldable
|
} cond ; foldable
|
||||||
|
|
|
@ -25,10 +25,8 @@ M: ratio number=
|
||||||
: ratio+d ( a/b c/d -- b*d )
|
: ratio+d ( a/b c/d -- b*d )
|
||||||
denominator swap denominator * ; inline
|
denominator swap denominator * ; inline
|
||||||
|
|
||||||
M: ratio >integer >fraction /i ;
|
M: ratio >fixnum >fraction /i >fixnum ;
|
||||||
|
M: ratio >bignum >fraction /i >bignum ;
|
||||||
M: ratio >fixnum >integer >fixnum ;
|
|
||||||
M: ratio >bignum >integer >bignum ;
|
|
||||||
|
|
||||||
M: ratio < scale < ;
|
M: ratio < scale < ;
|
||||||
M: ratio <= scale <= ;
|
M: ratio <= scale <= ;
|
||||||
|
|
Loading…
Reference in New Issue