summaryrefslogtreecommitdiffstats
path: root/arith.h
Commit message (Collapse)AuthorAgeFilesLines
* Update copyright notices from 2014 to 2015.Kaz Kylheku2015-02-011-1/+1
| | | | | | | | | | | * arith.c, arith.h, combi.c, combi.h, debug.c, debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, sysif.c, sysif.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Update. * LICENSE, METALICENSE: Likewise.
* * arith.c (width): New function.Kaz Kylheku2015-01-271-0/+1
| | | | | | | | * arith.h (width): Declared. * eval.c (eval_init): Width registered as intrisinc. * txr.1: Documented width.
* * Makefile, arith.c, arith.h, combi.c, combi.h, configure, debug.c,Kaz Kylheku2014-07-231-16/+16
| | | | | | | | debug.h, eval.c, eval.h, filter.c, filter.h, gc.c, gc.h, hash.c, hash.h, lib.c, lib.h, match.c, match.h, parser.h, parser.l, parser.y, rand.c, rand.h, regex.c, regex.h, signal.c, signal.h, stream.c, stream.h, syslog.c, syslog.h, txr.c, txr.h, unwind.c, unwind.h, utf8.c, utf8.h: Synchronize license header with LICENSE.
* * arith.c (tofloat, toint): New functions.Kaz Kylheku2014-03-191-0/+2
| | | | | | | | | * arith.h (tofloat, toint): Declared. * eval.c (eval_init): tofloat and toint registered as intrinsics. * txr.1: Documented.
* * arith.c (rising_product): New static function.Kaz Kylheku2014-01-111-0/+2
| | | | | | | | | | (n_choose_k, n_perm_k): New functions. * arith.h (n_choose_k, n_perm_k): Declared. * eval.c (eval_init): New functions interned. * txr.1: Documented.
* * arith.c (to_float): Print function name as ~a rather than ~s,Kaz Kylheku2014-01-111-0/+1
| | | | | | | | | | | | so it doesn't have quotes around it. (cum_norm_dist): New function. * arith.h (cum_norm_dist): Declared. * eval.c: Include arith.h. (eval_init): Register cum_norm_dist as intrinsic. * txr.1: Documented cum-norm-dist.
* Bumping copyrights to 2014 and expressing them as year ranges.Kaz Kylheku2013-12-101-1/+1
| | | | Fixing some errors in copyright comments.
* * arith.c (bignum_from_long): New function.Kaz Kylheku2012-10-011-0/+1
| | | | | | | | | * arith.h (bignum_from_long): Declared. * lib.c (int_str): Streamlined. Only use mp_read_radix in the case when wcstol fails, because now we have bignum_from_long to handle all values of long. Ensure that the bignum is normalized, in case it falls in the fixnum range (does not happen on our usual platforms).
* * arith.c (INT_PTR_MAX_MP): New static variable.Kaz Kylheku2012-04-101-0/+1
| | | | | | | | | | | | | | | (in_int_ptr_range): New function. (arith_init): Initialize INT_PTR_MAX_MP. * arith.h (in_int_ptr_range): Declared. * lib.c (c_num): Allow bignums to be converted to a cnum, if they are in range, rather than allowing only fixnums. * rand.c (make_random_state): Now that we have such a function, initialize random seed using time value from time_sec_usec rather than from time and clock. clock is bad for random seeding because it measures virtual time since the start of the process.
* * arith.c (bignum): Previously static function now exposed as external.Kaz Kylheku2012-04-081-0/+1
| | | | | | | | | | | | | | | | | | | | * arith.h (bignum): Declared. * configure: Added check for tm_gmtoff and tm_tmzone fields being present in struct tm. * eval.c (eval_init): New intrinsic functions: time, time-usec. * lib.c (num): If the cnum is outside of the fixnum range, then construct a bignum. (time_sec, time_sec_usec): New functions. * lib.h (mut): Slight change to macro to eliminate compiler warning. (time_sec, time_sec_usec): Declared. * txr.1: Stub section for time and time-usec. * txr.vim: Highlighting for time and time-usec.
* * arith.c: Updated copyright year.Kaz Kylheku2012-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * arith.h: Likewise. * debug.c: Added copyright header. * debug.h: Updated copyright year. * eval.c: Likewise. * eval.h: Likewise. * filter.c: Likewise. * filter.h: Likewise. * gc.c: Likewise. * gc.h: Likewise. * hash.c: Likewise. * hash.h: Likewise. * lib.c: Likewise. * lib.h: Likewise. * match.c: Likewise. * match.h: Likewise. * parser.h: Likewise. * regex.c: Likewise. * regex.h: Likewise. * stream.c: Likewise. * stream.h: Likewise. * txr.c: Likewise, and e-mail address. * txr.h: Updated copyright year. * unwind.c: Likewise. * unwind.h: Likewise.
* * arith.c (highest_bit): Changing to external linkage.Kaz Kylheku2011-12-231-0/+1
| | | | | | | | * arith.h (highest_bit): Declared. * rand.c (random): Rewrote using different algorithm which ensures even distribution, and avoids doing a bignum mod operation.
* * arith.c (normalize): Linkage changed to extern.Kaz Kylheku2011-12-211-0/+1
| | | | | | | | * arith.h (normalize): Declared. * rand.c (random): Bugfix: normalize the bignum before returning it. * txr.1: Doc stubs for PRNG functionality.
* Bignum support, here we go!Kaz Kylheku2011-12-091-0/+28
Bignums, based on Michael Fromberger's MPI library, are integrated into the input syntax, stream output, equality testing, the garbage collector, and hashing. The plus operation handles transitions between fixnums and bignums. Other operations are still fixnum only. * Makefile (CFLAGS): Add mpi directory to include file search. (OBJS): Include new arith.o module and all of MPI_OBJS. (MPI_OBJS, MPI_OBJS_BASE): New variables. * configure (mpi_version, have_quilt, have_patch): New variables. Script detects whether patch and quilt are available. Unpacks mpi library, applies patches. Detects 128 bit integer type. Records more information in config.h about the sizes of types. * dep.mk: Updated. * depend.txr: Make work with paths that have directory components. * eval.c (eval_init): Rename of nump to fixnump. * gc.c (finalize, mark_obj): Handle BGNUM case. * hash.c: (hash_c_str): Changed to return unsigned long instead of long. (equal_hash): Handle BGNUM case. (eql_hash): Handle bignums with equal-hash, but other objects as eq. * lib.c (num_s): Variable renamed to fixnum_s. (bignum_s): New symbol variable. (code2type): Follow rename of num_s. Handle BGNUM case. (typeof): Follow rename of num_s. (eql): Handle bignums using equal, and other types using eq. (equal): Handle BGNUM case. (chk_calloc): New function. (c_num): Wording change in error message: is not a fixnum. (nump): Renamed to fixnump. (bignump): New function. (plus): Function removed, reimplemented in arith.c. (int_str): Handle integers which are too large for wcstol using bignum conversion. Base 0 is no longer passed to wcstol but converted to 10 because the special semantics for 0 would be inconsistent for bignums. (obj_init): Follow rename of num_s. Initialize bignum_s.