Merge branch 'master' of git://factorcode.org/git/factor
commit
05be076b5f
|
@ -0,0 +1,17 @@
|
|||
! Copyright (C) 2009 Doug Coleman.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: tools.test project-euler.common ;
|
||||
IN: project-euler.common.tests
|
||||
|
||||
[ 4 ] [ -1000 number-length ] unit-test
|
||||
[ 3 ] [ -999 number-length ] unit-test
|
||||
[ 3 ] [ -100 number-length ] unit-test
|
||||
[ 2 ] [ -99 number-length ] unit-test
|
||||
[ 1 ] [ -9 number-length ] unit-test
|
||||
[ 1 ] [ -1 number-length ] unit-test
|
||||
[ 1 ] [ 0 number-length ] unit-test
|
||||
[ 1 ] [ 9 number-length ] unit-test
|
||||
[ 2 ] [ 99 number-length ] unit-test
|
||||
[ 3 ] [ 100 number-length ] unit-test
|
||||
[ 3 ] [ 999 number-length ] unit-test
|
||||
[ 4 ] [ 1000 number-length ] unit-test
|
|
@ -76,7 +76,12 @@ PRIVATE>
|
|||
[ dup 0 = not ] [ 10 /mod ] produce reverse nip ;
|
||||
|
||||
: number-length ( n -- m )
|
||||
log10 floor 1 + >integer ;
|
||||
abs [
|
||||
1
|
||||
] [
|
||||
1 0 [ 2over >= ]
|
||||
[ [ 10 * ] [ 1 + ] bi* ] while 2nip
|
||||
] if-zero ;
|
||||
|
||||
: nth-prime ( n -- n )
|
||||
1 - lprimes lnth ;
|
||||
|
|
|
@ -38,7 +38,7 @@ inline static void *ucontext_stack_pointer(void *uap)
|
|||
inline static unsigned int uap_fpu_status(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
struct _fpstate *fpregs = (struct _fpstate *)uap->uc_mcontext.fpregs;
|
||||
struct _fpstate *fpregs = (struct _fpstate *)ucontext->uc_mcontext.fpregs;
|
||||
if (fpregs->magic == X86_FXSR_MAGIC)
|
||||
return fpregs->sw | fpregs->mxcsr;
|
||||
else
|
||||
|
@ -48,7 +48,7 @@ inline static unsigned int uap_fpu_status(void *uap)
|
|||
inline static void uap_clear_fpu_status(void *uap)
|
||||
{
|
||||
ucontext_t *ucontext = (ucontext_t *)uap;
|
||||
struct _fpstate *fpregs = (struct _fpstate *)uap->uc_mcontext.fpregs;
|
||||
struct _fpstate *fpregs = (struct _fpstate *)ucontext->uc_mcontext.fpregs;
|
||||
fpregs->sw = 0;
|
||||
if (fpregs->magic == X86_FXSR_MAGIC)
|
||||
fpregs->mxcsr &= 0xffffffc0;
|
||||
|
|
Loading…
Reference in New Issue