mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +03:00
Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3d55811205 | ||
|
296aa50ac7 |
23
CHANGES
23
CHANGES
@@ -5,6 +5,25 @@ The following are the changes from calc version 2.11.4t1 to date:
|
||||
Fixes cscript files to deal with the -S flag being replaced by
|
||||
-f and possibly other flags.
|
||||
|
||||
Added regression tests for builtin functions bernoulli, catalan,
|
||||
euler, freeeuler, and sleep. Added non-base 10 regression tests
|
||||
for digit, digits and places.
|
||||
|
||||
The bernoulli.cal script now just calls the bernoulli() builtin
|
||||
function. It remains for backward compatibility.
|
||||
|
||||
The Makefile now builds have_fpos_pos.h to determine if the
|
||||
a non-scalar FILEPOS has a __pos stucture element. If it does,
|
||||
the FILEPOS_BITS is taken to be the size of just the __pos element.
|
||||
|
||||
Misc fixes related to non-scalar (e.g., structure) FILEPOS. Fixed
|
||||
a compile problems where non-scalar FILEPOS were incorrectly assigned.
|
||||
|
||||
Fixed make depend rule.
|
||||
|
||||
Return an error on malloc / realloc failures for bernoulli and
|
||||
euler functions.
|
||||
|
||||
|
||||
The following are the changes from calc version 2.11.3t0 to 2.11.4:
|
||||
|
||||
@@ -5019,8 +5038,8 @@ Following is a list of visible changes to calc from version 1.24.7 to 1.26.1:
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.14 $
|
||||
## @(#) $Id: CHANGES,v 29.14 2000/12/15 14:58:20 chongo Exp $
|
||||
## @(#) $Revision: 29.16 $
|
||||
## @(#) $Id: CHANGES,v 29.16 2000/12/17 13:07:54 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/RCS/CHANGES,v $
|
||||
##
|
||||
## Under source code control: 1993/06/02 18:12:57
|
||||
|
135
Makefile
135
Makefile
@@ -20,8 +20,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.9 $
|
||||
# @(#) $Id: Makefile.ship,v 29.9 2000/06/07 15:50:19 chongo Exp $
|
||||
# @(#) $Revision: 29.10 $
|
||||
# @(#) $Id: Makefile.ship,v 29.10 2000/12/17 12:23:29 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/RCS/Makefile.ship,v $
|
||||
#
|
||||
# Under source code control: 1990/02/15 01:48:41
|
||||
@@ -42,7 +42,7 @@
|
||||
#
|
||||
# value meaning
|
||||
# -------- -------
|
||||
# (nothing) let the makefile guess at what you need
|
||||
# (nothing) let the Makefile guess at what you need
|
||||
# -DUSE_TERMIOS use struct termios from <termios.h>
|
||||
# -DUSE_TERMIO use struct termios from <termio.h>
|
||||
# -DUSE_SGTTY use struct sgttyb from <sys/ioctl.h>
|
||||
@@ -63,7 +63,7 @@ TERMCONTROL=
|
||||
# If you do not have vsprintf(), then calc will try sprintf() and hope
|
||||
# for the best.
|
||||
#
|
||||
# If HAVE_VSPRINTF is empty, this makefile will run the have_stdvs.c and/or
|
||||
# If HAVE_VSPRINTF is empty, this Makefile will run the have_stdvs.c and/or
|
||||
# have_varvs.c program to determine if vsprintf() is supported. If
|
||||
# HAVE_VSPRINTF is set to -DDONT_HAVE_VSPRINTF then calc will hope that
|
||||
# sprintf() will work.
|
||||
@@ -78,7 +78,7 @@ HAVE_VSPRINTF=
|
||||
# Big Endian: Amdahl, 68k, Pyramid, Mips, Sparc, ...
|
||||
# Little Endian: Vax, 32k, Spim (Dec Mips), i386, i486, ...
|
||||
#
|
||||
# If in doubt, leave BYTE_ORDER empty. This makefile will attempt to
|
||||
# If in doubt, leave BYTE_ORDER empty. This Makefile will attempt to
|
||||
# use BYTE_ORDER in <machine/endian.h> or it will attempt to run
|
||||
# the endian program. If you get syntax errors when you compile,
|
||||
# try forcing the value to be BIG_ENDIAN and run the calc regression
|
||||
@@ -92,7 +92,7 @@ BYTE_ORDER=
|
||||
|
||||
# Determine the number of bits in a long
|
||||
#
|
||||
# If in doubt, leave LONG_BITS empty. This makefile will run
|
||||
# If in doubt, leave LONG_BITS empty. This Makefile will run
|
||||
# the longbits program to determine the length.
|
||||
#
|
||||
# In order to avoid make brain damage in some systems, we avoid placing
|
||||
@@ -125,7 +125,7 @@ LONGLONG_BITS=
|
||||
# Determine if we have the ANSI C fgetpos and fsetpos alternate interface
|
||||
# to the ftell() and fseek() (with whence set to SEEK_SET) functions.
|
||||
#
|
||||
# If HAVE_FPOS is empty, this makefile will run the have_fpos program
|
||||
# If HAVE_FPOS is empty, this Makefile will run the have_fpos program
|
||||
# to determine if there is are fgetpos and fsetpos functions. If HAVE_FPOS
|
||||
# is set to -DHAVE_NO_FPOS, then calc will use ftell() and fseek().
|
||||
#
|
||||
@@ -134,11 +134,22 @@ LONGLONG_BITS=
|
||||
HAVE_FPOS=
|
||||
#HAVE_FPOS= -DHAVE_NO_FPOS
|
||||
|
||||
# Determine if we have an __pos element of a file position (fpos_t) structure.
|
||||
#
|
||||
# If HAVE_FPOS_POS is empty, this Makefile will run the have_fpos_pos program
|
||||
# to determine if fpos_t has a __pos structure element. If HAVE_FPOS_POS
|
||||
# is set to -DHAVE_NO_FPOS_POS, then calc assume there is no __pos element.
|
||||
#
|
||||
# If in doubt, leave HAVE_FPOS_POS empty and this Makefile will figure it out.
|
||||
#
|
||||
HAVE_FPOS_POS=
|
||||
#HAVE_FPOS= -DHAVE_NO_FPOS_POS
|
||||
|
||||
# Determine if we have an off_t which one can perform arithmetic operations,
|
||||
# assignments and comparisons. On some systems off_t is some sort of union
|
||||
# or struct.
|
||||
#
|
||||
# If HAVE_OFFSCL is empty, this makefile will run the have_offscl program
|
||||
# If HAVE_OFFSCL is empty, this Makefile will run the have_offscl program
|
||||
# to determine if off_t is a scalar. If HAVE_OFFSCL is set to the value
|
||||
# -DOFF_T_NON_SCALAR when calc will assume that off_t some sort of
|
||||
# union or struct which.
|
||||
@@ -153,7 +164,7 @@ HAVE_OFFSCL=
|
||||
# or struct. Some systems do not have an fpos_t and long is as a file
|
||||
# offset instead.
|
||||
#
|
||||
# If HAVE_POSSCL is empty, this makefile will run the have_offscl program
|
||||
# If HAVE_POSSCL is empty, this Makefile will run the have_offscl program
|
||||
# to determine if off_t is a scalar, or if there is no off_t and long
|
||||
# (a scalar) should be used instead. If HAVE_POSSCL is set to the value
|
||||
# -DFILEPOS_NON_SCALAR when calc will assume that fpos_t exists and is
|
||||
@@ -166,7 +177,7 @@ HAVE_POSSCL=
|
||||
|
||||
# Determine if we have ANSI C const.
|
||||
#
|
||||
# If HAVE_CONST is empty, this makefile will run the have_const program
|
||||
# If HAVE_CONST is empty, this Makefile will run the have_const program
|
||||
# to determine if const is supported. If HAVE_CONST is set to -DHAVE_NO_CONST,
|
||||
# then calc will not use const.
|
||||
#
|
||||
@@ -177,7 +188,7 @@ HAVE_CONST=
|
||||
|
||||
# Determine if we have uid_t
|
||||
#
|
||||
# If HAVE_UID_T is empty, this makefile will run the have_uid_t program
|
||||
# If HAVE_UID_T is empty, this Makefile will run the have_uid_t program
|
||||
# to determine if const is supported. If HAVE_UID_T is set to -DHAVE_NO_UID_T,
|
||||
# then calc will treat uid_t as an unsigned short. This only matters if
|
||||
# $HOME is not set and calc must look up the home directory in /etc/passwd.
|
||||
@@ -189,7 +200,7 @@ HAVE_UID_T=
|
||||
|
||||
# Determine if we have memcpy(), memset() and strchr()
|
||||
#
|
||||
# If HAVE_NEWSTR is empty, this makefile will run the have_newstr program
|
||||
# If HAVE_NEWSTR is empty, this Makefile will run the have_newstr program
|
||||
# to determine if memcpy(), memset() and strchr() are supported. If
|
||||
# HAVE_NEWSTR is set to -DHAVE_NO_NEWSTR, then calc will use bcopy() instead
|
||||
# of memcpy(), use bfill() instead of memset(), and use index() instead of
|
||||
@@ -202,7 +213,7 @@ HAVE_NEWSTR=
|
||||
|
||||
# Determine if we have memmove()
|
||||
#
|
||||
# If HAVE_MEMMOVE is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_MEMMOVE is empty, this Makefile will run the have_memmv program
|
||||
# to determine if memmove() is supported. If HAVE_MEMMOVE is set to
|
||||
# -DHAVE_NO_MEMMOVE, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -214,7 +225,7 @@ HAVE_MEMMOVE=
|
||||
|
||||
# Determine if we have ustat()
|
||||
#
|
||||
# If HAVE_USTAT is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_USTAT is empty, this Makefile will run the have_memmv program
|
||||
# to determine if ustat() is supported. If HAVE_USTAT is set to
|
||||
# -DHAVE_NO_USTAT, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -226,7 +237,7 @@ HAVE_USTAT=
|
||||
|
||||
# Determine if we have getsid()
|
||||
#
|
||||
# If HAVE_GETSID is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_GETSID is empty, this Makefile will run the have_memmv program
|
||||
# to determine if getsid() is supported. If HAVE_GETSID is set to
|
||||
# -DHAVE_NO_GETSID, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -238,7 +249,7 @@ HAVE_GETSID=
|
||||
|
||||
# Determine if we have getpgid()
|
||||
#
|
||||
# If HAVE_GETPGID is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_GETPGID is empty, this Makefile will run the have_memmv program
|
||||
# to determine if getpgid() is supported. If HAVE_GETPGID is set to
|
||||
# -DHAVE_NO_GETPGID, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -250,7 +261,7 @@ HAVE_GETPGID=
|
||||
|
||||
# Determine if we have clock_gettime()
|
||||
#
|
||||
# If HAVE_GETTIME is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_GETTIME is empty, this Makefile will run the have_memmv program
|
||||
# to determine if clock_gettime() is supported. If HAVE_GETTIME is set to
|
||||
# -DHAVE_NO_GETTIME, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -262,7 +273,7 @@ HAVE_GETTIME=
|
||||
|
||||
# Determine if we have getprid()
|
||||
#
|
||||
# If HAVE_GETPRID is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_GETPRID is empty, this Makefile will run the have_memmv program
|
||||
# to determine if getprid() is supported. If HAVE_GETPRID is set to
|
||||
# -DHAVE_NO_GETPRID, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -274,7 +285,7 @@ HAVE_GETPRID=
|
||||
|
||||
# Determine if we have /dev/urandom
|
||||
#
|
||||
# If HAVE_URANDOM is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_URANDOM is empty, this Makefile will run the have_memmv program
|
||||
# to determine if /dev/urandom is supported. If HAVE_URANDOM is set to
|
||||
# -DHAVE_NO_URANDOM, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -286,7 +297,7 @@ HAVE_URANDOM=
|
||||
|
||||
# Determine if we have getrusage()
|
||||
#
|
||||
# If HAVE_GETRUSAGE is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_GETRUSAGE is empty, this Makefile will run the have_memmv program
|
||||
# to determine if getrusage() is supported. If HAVE_GETRUSAGE is set to
|
||||
# -DHAVE_NO_GETRUSAGE, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -298,7 +309,7 @@ HAVE_GETRUSAGE=
|
||||
|
||||
# Determine if we have strdup()
|
||||
#
|
||||
# If HAVE_STRDUP is empty, this makefile will run the have_memmv program
|
||||
# If HAVE_STRDUP is empty, this Makefile will run the have_memmv program
|
||||
# to determine if strdup() is supported. If HAVE_STRDUP is set to
|
||||
# -DHAVE_NO_STRDUP, then calc will use internal functions to simulate
|
||||
# the memory move function that does correct overlapping memory modes.
|
||||
@@ -824,8 +835,8 @@ ECHO= /bin/echo
|
||||
|
||||
# Makefile debug
|
||||
#
|
||||
# Q=@ do not echo internal makefile actions (quiet mode)
|
||||
# Q= echo internal makefile actions (debug / verbose mode)
|
||||
# Q=@ do not echo internal Makefile actions (quiet mode)
|
||||
# Q= echo internal Makefile actions (debug / verbose mode)
|
||||
#
|
||||
# V=@: do not echo debug statements (quiet mode)
|
||||
# V=@ do echo debug statements (debug / verbose mode)
|
||||
@@ -885,7 +896,7 @@ LIB_H_SRC= alloc.h blkcpy.h block.h byteswap.h calc.h cmath.h \
|
||||
# we build these .h files during the make
|
||||
#
|
||||
BUILD_H_SRC= align32.h args.h calcerr.h conf.h endian_calc.h \
|
||||
fposval.h have_const.h have_fpos.h have_malloc.h \
|
||||
fposval.h have_const.h have_fpos.h have_fpos_pos.h have_malloc.h \
|
||||
have_memmv.h have_newstr.h have_offscl.h have_posscl.h \
|
||||
have_stdlib.h have_string.h have_times.h have_uid_t.h \
|
||||
have_unistd.h longbits.h longlong.h terminal.h \
|
||||
@@ -903,7 +914,7 @@ BUILD_C_SRC= calcerr.c
|
||||
#
|
||||
UTIL_C_SRC= align32.c endian.c longbits.c have_newstr.c have_uid_t.c \
|
||||
have_const.c have_stdvs.c have_varvs.c fposval.c have_fpos.c \
|
||||
longlong.c have_offscl.c have_posscl.c have_memmv.c \
|
||||
have_fpos_pos.c longlong.c have_offscl.c have_posscl.c have_memmv.c \
|
||||
have_ustat.c have_getsid.c have_getpgid.c \
|
||||
have_gettime.c have_getprid.c have_rusage.c have_strdup.c
|
||||
|
||||
@@ -918,8 +929,8 @@ UTIL_MISC_SRC= calcerr_h.sed calcerr_h.awk calcerr_c.sed calcerr_c.awk \
|
||||
# There MUST be a .o for every .c in UTIL_C_SRC.
|
||||
#
|
||||
UTIL_OBJS= endian.o longbits.o have_newstr.o have_uid_t.o \
|
||||
have_const.o fposval.o have_fpos.o longlong.o try_strarg.o \
|
||||
have_stdvs.o have_varvs.o have_posscl.o have_memmv.o \
|
||||
have_const.o fposval.o have_fpos.o have_fpos_pos.o longlong.o \
|
||||
try_strarg.o have_stdvs.o have_varvs.o have_posscl.o have_memmv.o \
|
||||
have_ustat.o have_getsid.o have_getpgid.o \
|
||||
have_gettime.o have_getprid.o ver_calc.o have_rusage.o have_strdup.o
|
||||
|
||||
@@ -936,7 +947,7 @@ UTIL_PROGS= align32 fposval have_uid_t longlong have_const \
|
||||
have_ustat have_getsid have_getpgid \
|
||||
have_gettime have_getprid ver_calc have_strdup
|
||||
|
||||
# The complete list of makefile vars passed down to custom/Makefile.
|
||||
# The complete list of Makefile vars passed down to custom/Makefile.
|
||||
#
|
||||
CUSTOM_PASSDOWN= Q="${Q}" \
|
||||
TOPDIR="${TOPDIR}" \
|
||||
@@ -964,7 +975,7 @@ CUSTOM_PASSDOWN= Q="${Q}" \
|
||||
MAKEDEPEND=${MAKEDEPEND} \
|
||||
SORT=${SORT}
|
||||
|
||||
# The complete list of makefile vars passed down to sample/Makefile.
|
||||
# The complete list of Makefile vars passed down to sample/Makefile.
|
||||
#
|
||||
SAMPLE_PASSDOWN= Q="${Q}" \
|
||||
TOPDIR="${TOPDIR}" \
|
||||
@@ -991,7 +1002,7 @@ SAMPLE_PASSDOWN= Q="${Q}" \
|
||||
CHMOD=${CHMOD} \
|
||||
SORT=${SORT}
|
||||
|
||||
# The compelte list of makefile vars passed down to help/Makefile.
|
||||
# The compelte list of Makefile vars passed down to help/Makefile.
|
||||
#
|
||||
HELP_PASSDOWN= Q="${Q}" \
|
||||
TOPDIR="${TOPDIR}" \
|
||||
@@ -1005,7 +1016,7 @@ HELP_PASSDOWN= Q="${Q}" \
|
||||
CHMOD=${CHMOD} \
|
||||
FMT=${FMT}
|
||||
|
||||
# The compelte list of makefile vars passed down to cal/Makefile.
|
||||
# The compelte list of Makefile vars passed down to cal/Makefile.
|
||||
#
|
||||
CAL_PASSDOWN= Q="${Q}" \
|
||||
TOPDIR="${TOPDIR}" \
|
||||
@@ -1013,7 +1024,7 @@ CAL_PASSDOWN= Q="${Q}" \
|
||||
MAKE_FILE=${MAKE_FILE} \
|
||||
CHMOD=${CHMOD}
|
||||
|
||||
# The compelte list of makefile vars passed down to cscript/Makefile.
|
||||
# The compelte list of Makefile vars passed down to cscript/Makefile.
|
||||
#
|
||||
CSCRIPT_PASSDOWN= Q="${Q}" \
|
||||
BINDIR="${BINDIR}" \
|
||||
@@ -1559,7 +1570,51 @@ have_fpos.h: have_fpos.c ${MAKE_FILE}
|
||||
true; \
|
||||
fi
|
||||
|
||||
fposval.h: fposval.c have_fpos.h have_offscl.h have_posscl.h \
|
||||
have_fpos_pos.h: have_fpos_pos.c have_fpos.h have_posscl.h ${MAKE_FILE}
|
||||
-${Q}rm -f have_fpos_pos have_fpos_pos.o fpos_tmp have_fpos_pos.h
|
||||
${Q}echo 'forming have_fpos_pos.h'
|
||||
${Q}echo '/*' > have_fpos_pos.h
|
||||
${Q}echo ' * DO NOT EDIT -- generated by the Makefile' \
|
||||
>> have_fpos_pos.h
|
||||
${Q}echo ' */' >> have_fpos_pos.h
|
||||
${Q}echo '' >> have_fpos_pos.h
|
||||
${Q}echo '' >> have_fpos_pos.h
|
||||
${Q}echo '#if !defined(__HAVE_FPOS_POS_H__)' >> have_fpos_pos.h
|
||||
${Q}echo '#define __HAVE_FPOS_POS_H__' >> have_fpos_pos.h
|
||||
${Q}echo '' >> have_fpos_pos.h
|
||||
${Q}echo '' >> have_fpos_pos.h
|
||||
${Q}echo '/* do we have fgetpos & fsetpos functions? */' \
|
||||
>> have_fpos_pos.h
|
||||
-${Q}rm -f have_fpos_pos.o have_fpos_pos
|
||||
-${Q}${LCC} ${HAVE_FPOS_POS} ${ICFLAGS} have_fpos_pos.c -c \
|
||||
2>/dev/null; true
|
||||
-${Q}${LCC} ${ILDFLAGS} have_fpos_pos.o -o have_fpos_pos \
|
||||
2>/dev/null; true
|
||||
-${Q}${SHELL} -c "./have_fpos_pos > fpos_tmp 2>/dev/null" \
|
||||
>/dev/null 2>&1; true
|
||||
-${Q}if [ -s fpos_tmp ]; then \
|
||||
cat fpos_tmp >> have_fpos_pos.h; \
|
||||
else \
|
||||
echo '#undef HAVE_FPOS_POS /* no */' >> have_fpos_pos.h; \
|
||||
echo '' >> have_fpos_pos.h; \
|
||||
echo '#undef FPOS_POS_BITS' >> have_fpos_pos.h; \
|
||||
fi
|
||||
${Q}echo '' >> have_fpos_pos.h
|
||||
${Q}echo '' >> have_fpos_pos.h
|
||||
${Q}echo '#endif /* !__HAVE_FPOS_POS_H__ */' >> have_fpos_pos.h
|
||||
-${Q}rm -f have_fpos_pos have_fpos_pos.o fpos_tmp
|
||||
${Q}echo 'have_fpos_pos.h formed'
|
||||
-@if [ -z "${Q}" ]; then \
|
||||
echo ''; \
|
||||
echo '=-=-= start of $@ =-=-='; \
|
||||
cat $@; \
|
||||
echo '=-=-= end of $@ =-=-='; \
|
||||
echo ''; \
|
||||
else \
|
||||
true; \
|
||||
fi
|
||||
|
||||
fposval.h: fposval.c have_fpos.h have_fpos_pos.h have_offscl.h have_posscl.h \
|
||||
endian_calc.h ${MAKE_FILE}
|
||||
-${Q}rm -f fposv_tmp fposval fposval.o fposval.h
|
||||
${Q}echo 'forming fposval.h'
|
||||
@@ -2423,7 +2478,7 @@ sample/all:
|
||||
|
||||
##
|
||||
#
|
||||
# The BSDI cdrom makefile expects certain files to be pre-built in a sub-dir
|
||||
# The BSDI cdrom Makefile expects certain files to be pre-built in a sub-dir
|
||||
# called gen_h. This rule creats this sub-directory so that the release can
|
||||
# be shipped off to BSDI. You can ignore this rule.
|
||||
#
|
||||
@@ -2591,15 +2646,15 @@ chk: ./cal/regress.cal
|
||||
# debug
|
||||
#
|
||||
# make env:
|
||||
# * print major makefile variables
|
||||
# * print major Makefile variables
|
||||
#
|
||||
# make mkdebug:
|
||||
# * print major makefile variables
|
||||
# * print major Makefile variables
|
||||
# * build anything not yet built
|
||||
#
|
||||
# make debug:
|
||||
# * remove everything that was previously built
|
||||
# * print major makefile variables
|
||||
# * print major Makefile variables
|
||||
# * make everything
|
||||
# * run the regression tests
|
||||
##
|
||||
@@ -2612,6 +2667,7 @@ env:
|
||||
@echo "LONG_BITS=${LONG_BITS}"; echo ""
|
||||
@echo "LONGLONG_BITS=${LONGLONG_BITS}"; echo ""
|
||||
@echo "HAVE_FPOS=${HAVE_FPOS}"; echo ""
|
||||
@echo "HAVE_FPOS_POS=${HAVE_FPOS_POS}"; echo ""
|
||||
@echo "HAVE_OFFSCL=${HAVE_OFFSCL}"; echo ""
|
||||
@echo "HAVE_POSSCL=${HAVE_POSSCL}"; echo ""
|
||||
@echo "HAVE_CONST=${HAVE_CONST}"; echo ""
|
||||
@@ -3282,6 +3338,7 @@ file.o: fposval.h
|
||||
file.o: hash.h
|
||||
file.o: have_const.h
|
||||
file.o: have_fpos.h
|
||||
file.o: have_fpos_pos.h
|
||||
file.o: have_malloc.h
|
||||
file.o: have_memmv.h
|
||||
file.o: have_newstr.h
|
||||
@@ -3299,6 +3356,7 @@ file.o: zmath.h
|
||||
fposval.o: endian_calc.h
|
||||
fposval.o: fposval.c
|
||||
fposval.o: have_fpos.h
|
||||
fposval.o: have_fpos_pos.h
|
||||
fposval.o: have_offscl.h
|
||||
fposval.o: have_posscl.h
|
||||
func.o: alloc.h
|
||||
@@ -3369,6 +3427,9 @@ hash.o: zrand.h
|
||||
hash.o: zrandom.h
|
||||
have_const.o: have_const.c
|
||||
have_fpos.o: have_fpos.c
|
||||
have_fpos_pos.o: have_fpos.h
|
||||
have_fpos_pos.o: have_fpos_pos.c
|
||||
have_fpos_pos.o: have_posscl.h
|
||||
have_getpgid.o: have_getpgid.c
|
||||
have_getprid.o: have_getprid.c
|
||||
have_getsid.o: have_getsid.c
|
||||
|
12
cal/README
12
cal/README
@@ -116,6 +116,10 @@ bernoulli.cal
|
||||
|
||||
Calculate the nth Bernoulli number.
|
||||
|
||||
NOTE: There is now a bernoulli() builtin function. This file is
|
||||
left here for backward compatibility and now simply returns
|
||||
the buildin function.
|
||||
|
||||
|
||||
bigprime.cal
|
||||
|
||||
@@ -681,7 +685,7 @@ test8400.cal
|
||||
|
||||
test8400() defined
|
||||
|
||||
This resource file is used by regress.cal to check for quit-based
|
||||
This resource file is used by regress.cal to check for quit-based
|
||||
memory leaks.
|
||||
|
||||
test8500.cal
|
||||
@@ -702,7 +706,7 @@ test8600.cal
|
||||
global max_8600
|
||||
global hash_8600
|
||||
global hmean_8600
|
||||
|
||||
|
||||
This resource file is used by regress.cal to test a change of
|
||||
allowing up to 1024 args to be passed to a builtin function.
|
||||
|
||||
@@ -752,8 +756,8 @@ xx_print.cal
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: README,v 29.3 2000/12/04 20:11:52 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: README,v 29.4 2000/12/17 12:26:04 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/README,v $
|
||||
##
|
||||
## Under source code control: 1990/02/15 01:50:32
|
||||
|
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* bernoulli - clculate the Nth Bernoulli number B(n)
|
||||
*
|
||||
* Copyright (C) 1999 David I. Bell
|
||||
* Copyright (C) 2000 David I. Bell and Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: bernoulli.cal,v 29.2 2000/06/07 14:02:25 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: bernoulli.cal,v 29.3 2000/12/17 12:26:04 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/bernoulli.cal,v $
|
||||
*
|
||||
* Under source code control: 1991/09/30 11:18:41
|
||||
@@ -29,12 +29,16 @@
|
||||
|
||||
/*
|
||||
* Calculate the Nth Bernoulli number B(n).
|
||||
* This uses the following symbolic formula to calculate B(n):
|
||||
*
|
||||
* NOTE: This is now a bulitin function.
|
||||
*
|
||||
* The non-buildin code used the following symbolic formula to calculate B(n):
|
||||
*
|
||||
* (b+1)^(n+1) - b^(n+1) = 0
|
||||
*
|
||||
* where b is a dummy value, and each power b^i gets replaced by B(i).
|
||||
* For example, for n = 3:
|
||||
*
|
||||
* (b+1)^4 - b^4 = 0
|
||||
* b^4 + 4*b^3 + 6*b^2 + 4*b + 1 - b^4 = 0
|
||||
* 4*b^3 + 6*b^2 + 4*b + 1 = 0
|
||||
@@ -48,11 +52,14 @@
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
static Bnmax;
|
||||
static mat Bn[1001];
|
||||
*/
|
||||
|
||||
define B(n)
|
||||
{
|
||||
/*
|
||||
local nn, np1, i, sum, mulval, divval, combval;
|
||||
|
||||
if (!isint(n) || (n < 0))
|
||||
@@ -85,4 +92,6 @@ define B(n)
|
||||
}
|
||||
Bnmax = n;
|
||||
return Bn[n];
|
||||
*/
|
||||
return bernoulli(n);
|
||||
}
|
||||
|
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.5 $
|
||||
* @(#) $Id: regress.cal,v 29.5 2000/12/04 20:00:53 chongo Exp $
|
||||
* @(#) $Revision: 29.6 $
|
||||
* @(#) $Id: regress.cal,v 29.6 2000/12/17 12:26:42 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/cal/RCS/regress.cal,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:50:36
|
||||
@@ -1223,7 +1223,85 @@ define test_functions()
|
||||
vrfy(hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1),
|
||||
'1112: hnrmod(21<<500+7,3,500,-1) == (21<<500+7)%(3<<500-1)');
|
||||
|
||||
print '1113: Ending test_functions';
|
||||
/*
|
||||
* catalan testing
|
||||
*/
|
||||
vrfy(catalan(2) == 2, '1113: catalan(2) == 2');
|
||||
vrfy(catalan(3) == 5, '1114: catalan(3) == 5');
|
||||
vrfy(catalan(4) == 14, '1115: catalan(4) == 14');
|
||||
vrfy(catalan(20) == 6564120420, '1116: catalan(20) == 6564120420');
|
||||
|
||||
/*
|
||||
* bernoulli builtin function testing
|
||||
*/
|
||||
vrfy(bernoulli(0) == 1, '1117: bernoulli(0) == 1');
|
||||
vrfy(bernoulli(1) == -1/2, '1118: bernoulli(1) == -1/2');
|
||||
vrfy(bernoulli(2) == 1/6, '1119: bernoulli(2) == 1/6');
|
||||
vrfy(bernoulli(3) == 0, '1120: bernoulli(3) == 0');
|
||||
vrfy(bernoulli(4) == -1/30, '1121: bernoulli(4) == -1/30');
|
||||
vrfy(bernoulli(5) == 0, '1122: bernoulli(5) == 0');
|
||||
vrfy(bernoulli(6) == 1/42, '1123: bernoulli(6) == 1/42');
|
||||
vrfy(bernoulli(32) == -7709321041217/510,
|
||||
'1124: bernoulli(32) == -7709321041217/510');
|
||||
|
||||
/*
|
||||
* euler function testing
|
||||
*/
|
||||
vrfy(euler(0) == 1, '1125: euler(0) == 1');
|
||||
vrfy(euler(1) == 0, '1126: euler(1) == 0');
|
||||
vrfy(euler(2) == -1, '1127: euler(2) == -1');
|
||||
vrfy(euler(3) == 0, '1128: euler(3) == 0');
|
||||
vrfy(freeeuler() == null(), '1129: freeeuler() == null()');
|
||||
vrfy(euler(4) == 5, '1130: euler(4) == 5');
|
||||
vrfy(euler(5) == 0, '1131: euler(5) == 0');
|
||||
vrfy(euler(6) == -61, '1132: euler(6) == -61');
|
||||
vrfy(euler(32) == 177519391579539289436664789665,
|
||||
'1130: euler(32) == 177519391579539289436664789665');
|
||||
vrfy(freeeuler() == null(), '1133: freeeuler() == null()');
|
||||
|
||||
/*
|
||||
* digit with non-10 base
|
||||
*/
|
||||
a = 123456.789;
|
||||
print '1134: a = 123456.789';
|
||||
vrfy(digit(a, 6, 100) == 0, '1135: digit(a, 6, 100) == 0');
|
||||
vrfy(digit(a, 5, 100) == 0, '1136: digit(a, 5, 100) == 0');
|
||||
vrfy(digit(a, 4, 100) == 0, '1137: digit(a, 4, 100) == 0');
|
||||
vrfy(digit(a, 3, 100) == 0, '1138: digit(a, 3, 100) == 0');
|
||||
vrfy(digit(a, 2, 100) == 12, '1139: digit(a, 2, 100) == 12');
|
||||
vrfy(digit(a, 1, 100) == 34, '1140: digit(a, 1, 100) == 34');
|
||||
vrfy(digit(a, 0, 100) == 56, '1141: digit(a, 0, 100) == 56');
|
||||
vrfy(digit(a, -1, 100) == 78, '1142: digit(a, -1, 100) == 78');
|
||||
vrfy(digit(a, -2, 100) == 90, '1143: digit(a, -2, 100) == 90');
|
||||
vrfy(digit(a, -3, 100) == 0, '1144: digit(a, -3, 100) == 0');
|
||||
vrfy(digit(a, -4, 100) == 0, '1145: digit(a, -4, 100) == 0');
|
||||
vrfy(digit(a, -5, 100) == 0, '1146: digit(a, -5, 100) == 0');
|
||||
vrfy(digit(a, -6, 100) == 0, '1146: digit(a, -6, 100) == 0');
|
||||
|
||||
/*
|
||||
* digits with a non-10 base
|
||||
*/
|
||||
vrfy(digits(a, 100) == 3, '1147: digits(a, 100) == 3');
|
||||
vrfy(digits(2^256-1, 256) == 32,'1148: digits(2^256-1, 256) == 32');
|
||||
|
||||
/*
|
||||
* places with a non-10 base
|
||||
*/
|
||||
vrfy(places(0.0123, 2) == -1, '1149: places(0.0123, 2) == -1');
|
||||
vrfy(places(0.625, 2) == 3, '1150: places(0.625, 2) == 3');
|
||||
vrfy(places(0.625, 8) == 1, '1151: places(0.625, 8) == 1');
|
||||
vrfy(places(171/2^712, 2) == 712,
|
||||
'1152: places(171/2^7120.625, 2) == 712');
|
||||
vrfy(places(171/2^712, 64) == 119,
|
||||
'1152: places(171/2^7120.625, 64) == 119');
|
||||
|
||||
/*
|
||||
* verify sleep
|
||||
*/
|
||||
vrfy(sleep(1/5) == null(), '1153: sleep(1/5) == null()');
|
||||
vrfy(sleep(1) == null(), '1154: sleep(1) == null()');
|
||||
|
||||
print '1155: Ending test_functions';
|
||||
}
|
||||
print '017: parsed test_functions()';
|
||||
|
||||
|
@@ -18,8 +18,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: Makefile,v 29.2 2000/06/07 14:03:03 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: Makefile,v 29.3 2000/12/17 12:28:15 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/custom/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/03/09 02:28:54
|
||||
@@ -406,7 +406,10 @@ depend:
|
||||
echo '#endif /* '"$$tag"' */' >> "skel/custom/$$i"; \
|
||||
done
|
||||
${Q}(cd ..; ${MAKE} hsrc)
|
||||
${Q}for i in `cd ..; ${MAKE} h_list`; do \
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'`; do \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
|
10
file.c
10
file.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: file.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: file.c,v 29.3 2000/12/17 12:24:42 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/file.c,v $
|
||||
*
|
||||
* Under source code control: 1991/07/20 00:21:56
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "calc.h"
|
||||
#include "longbits.h"
|
||||
#include "have_fpos.h"
|
||||
#include "have_fpos_pos.h"
|
||||
#include "fposval.h"
|
||||
#include "file.h"
|
||||
#include "calcerr.h"
|
||||
@@ -1239,7 +1240,8 @@ z2filepos(ZVALUE zpos)
|
||||
if (!zgtmaxfull(zpos)) {
|
||||
/* ztofull puts the value into native byte order */
|
||||
pos = ztofull(zpos);
|
||||
ret = pos;
|
||||
memset(&ret, 0, sizeof(FILEPOS));
|
||||
memcpy((void *)&ret, (void *)&pos, sizeof(pos));
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1251,7 +1253,7 @@ z2filepos(ZVALUE zpos)
|
||||
memcpy(&tmp, zpos.v, sizeof(FILEPOS));
|
||||
} else {
|
||||
/* copy what bits we can into the temp value */
|
||||
tmp = 0;
|
||||
memset(&tmp, 0, sizeof(FILEPOS));
|
||||
memcpy(&tmp, zpos.v, zpos.len*BASEB/8);
|
||||
}
|
||||
/* swap into native byte order */
|
||||
|
14
fposval.c
14
fposval.c
@@ -17,8 +17,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.2 $
|
||||
* @(#) $Id: fposval.c,v 29.2 2000/06/07 14:02:13 chongo Exp $
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: fposval.c,v 29.3 2000/12/17 12:25:36 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/fposval.c,v $
|
||||
*
|
||||
* Under source code control: 1994/11/05 03:19:52
|
||||
@@ -63,6 +63,7 @@
|
||||
#include "endian_calc.h"
|
||||
#include "have_offscl.h"
|
||||
#include "have_posscl.h"
|
||||
#include "have_fpos_pos.h"
|
||||
|
||||
char *program; /* our name */
|
||||
|
||||
@@ -83,9 +84,14 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* print the file position information
|
||||
*/
|
||||
#if defined(HAVE_FPOS_POS)
|
||||
printf("#undef FILEPOS_BITS\n");
|
||||
printf("#define FILEPOS_BITS %d\n", FPOS_POS_BITS);
|
||||
#else /* ! HAVE_FPOS_POS */
|
||||
fileposlen = sizeof(FILEPOS)*8;
|
||||
printf("#undef FILEPOS_BITS\n");
|
||||
printf("#define FILEPOS_BITS %d\n", fileposlen);
|
||||
#endif /* ! HAVE_FPOS_POS */
|
||||
#if CALC_BYTE_ORDER == BIG_ENDIAN
|
||||
/*
|
||||
* Big Endian
|
||||
@@ -113,8 +119,8 @@ main(int argc, char **argv)
|
||||
* Normally a "(*(dest) = *(src))" would do, but on some
|
||||
* systems a FILEPOS is not a scalar hince we must memcpy.
|
||||
*/
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t%s%d%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(",fileposlen,"))");
|
||||
printf("#define SWAP_HALF_IN_FILEPOS(dest, src)\t%s\n",
|
||||
"memcpy((void *)(dest), (void *)(src), sizeof(FPOS_POS_BITS))");
|
||||
#endif /* HAVE_FILEPOS_SCALAR */
|
||||
#endif /* CALC_BYTE_ORDER == BIG_ENDIAN */
|
||||
putchar('\n');
|
||||
|
59
have_fpos_pos.c
Normal file
59
have_fpos_pos.c
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* have_fpos_pos - Determine if a __pos element in FILEPOS
|
||||
*
|
||||
* Copyright (C) 2000 Landon Curt Noll
|
||||
*
|
||||
* Calc is open software; you can redistribute it and/or modify it under
|
||||
* the terms of the version 2.1 of the GNU Lesser General Public License
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* Calc is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
|
||||
* Public License for more details.
|
||||
*
|
||||
* A copy of version 2.1 of the GNU Lesser General Public License is
|
||||
* distributed with calc under the filename COPYING-LGPL. You should have
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.1 $
|
||||
* @(#) $Id: have_fpos_pos.c,v 29.1 2000/12/17 11:25:22 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/have_fpos_pos.c,v $
|
||||
*
|
||||
* Under source code control: 2000/12/17 01:23
|
||||
* File existed as early as: 2000
|
||||
*
|
||||
* chongo <was here> /\oo/\ http://www.isthe.com/chongo/
|
||||
* Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
|
||||
*/
|
||||
|
||||
/*
|
||||
* If the symbol HAVE_NO_FPOS is defined, we will output nothing.
|
||||
* If the HAVE_FILEPOS_SCALAR is defuned, we will output nothing.
|
||||
* If we are able to compile this program, then we must have the
|
||||
* __pos element in a non-scalar FILEPOS.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include "have_fpos.h"
|
||||
#include "have_posscl.h"
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
#if !defined(HAVE_NO_FPOS) && !defined(HAVE_FILEPOS_SCALAR)
|
||||
fpos_t pos; /* file position */
|
||||
|
||||
/* print a __pos element in fpos_t */
|
||||
printf("#undef HAVE_FPOS_POS\n");
|
||||
printf("#define HAVE_FPOS_POS 1 /* yes */\n\n");
|
||||
|
||||
/* determine __pos element size */
|
||||
printf("#undef FPOS_POS_BITS\n");
|
||||
printf("#define FPOS_POS_BITS %d\n\n", sizeof(pos.__pos)*8);
|
||||
#endif
|
||||
/* exit(0); */
|
||||
return 0;
|
||||
}
|
@@ -22,7 +22,7 @@ DESCRIPTION
|
||||
|
||||
Considerable runtime and memory are required for calculating
|
||||
bernoulli(n) for large even n. For n = 1000, the numerator has
|
||||
1779 digits, the denominator 9 digits.
|
||||
1779 digits, the denominator 9 digits.
|
||||
|
||||
The memory used to store calculated bernoulli numbers is freed by
|
||||
freebernoulli().
|
||||
@@ -57,8 +57,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: bernoulli,v 29.3 2000/12/14 10:32:24 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: bernoulli,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/bernoulli,v $
|
||||
##
|
||||
## Under source code control: 2000/07/13 01:33:00
|
||||
|
@@ -11,7 +11,7 @@ TYPES
|
||||
|
||||
DESCRIPTION
|
||||
If n >= 0, this returns the Catalan number for index n:
|
||||
|
||||
|
||||
catalan(n) = comb(2*n,n)/(n + 1)
|
||||
|
||||
Zero is returned for negative n.
|
||||
@@ -53,8 +53,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: catalan,v 29.1 2000/12/14 10:31:45 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: catalan,v 29.2 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/catalan,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
|
14
help/digit
14
help/digit
@@ -15,7 +15,7 @@ DESCRIPTION
|
||||
|
||||
d(x,n,b) returns the digit with index n in a standard base-b "decimal"
|
||||
representation of x, which may be described as follows:
|
||||
|
||||
|
||||
For an arbitrary base b >= 2, following the pattern of decimal (base 10)
|
||||
notation in elementary arithmetic, a base-b "decimal" representation of
|
||||
a positive real number may be considered to be specified by a finite or
|
||||
@@ -31,18 +31,18 @@ DESCRIPTION
|
||||
d_2 d_1 d_0 . d_-1 d_-2
|
||||
|
||||
represents the number
|
||||
|
||||
|
||||
d_2 * b^2 + d_1 * b + d0 + d_-1 * b^-1 + d_-2 * b^-2
|
||||
|
||||
The sequence of digits has to be infinite if den(x) has a prime factor
|
||||
which is not a factor of the base b. In cases where the representation
|
||||
may terminate, the digits are considered to continue with an infinite
|
||||
string of zeros rather than the other possibility of an infinite
|
||||
sequence of (b - 1)s. Thus, for the above example, d_n = 0 for
|
||||
sequence of (b - 1)s. Thus, for the above example, d_n = 0 for
|
||||
n = -3, -4, ... Similarly, a representation may be considered to
|
||||
continue with an infinite string of zeros on the left, so that in the
|
||||
above example d_n = 0 also for n >= 3.
|
||||
|
||||
|
||||
For negative x, digit(x,n,b) is given by digit(abs(x),n,b); the
|
||||
standard "decimal" representation of this x is a - sign followed by
|
||||
the representation of abs(x).
|
||||
@@ -71,7 +71,7 @@ EXAMPLE
|
||||
0 0 0 0 12 34 56 78 90 0 0 0 0
|
||||
|
||||
> for (n = 6; n >= -6; n--) print digit(a, n, 256),; print
|
||||
0 0 0 0 1 226 64 201 251 231 108 139 67
|
||||
0 0 0 0 1 226 64 201 251 231 108 139 67
|
||||
|
||||
> for (n = 1; n >= -12; n++) print digit(10/7, n),; print
|
||||
> 0 1 4 2 8 5 7 1 4 2 8 5 7 1
|
||||
@@ -108,8 +108,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: digit,v 29.3 2000/12/14 10:32:24 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: digit,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/digit,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:01
|
||||
|
@@ -29,7 +29,7 @@ EXAMPLE
|
||||
1 0 -1 0 5 0 -61
|
||||
|
||||
LIMITS
|
||||
none
|
||||
none
|
||||
|
||||
LINK LIBRARY
|
||||
NUMBER *qeuler(long n)
|
||||
@@ -53,8 +53,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: euler,v 29.1 2000/12/14 10:31:45 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: euler,v 29.2 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/euler,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
|
@@ -19,7 +19,7 @@ DESCRIPTION
|
||||
places(x,b) = n > 0 if and only if the fractional part of abs(x)
|
||||
has a finite base-b "decimal" representation with n digits of which
|
||||
the last digit is nonzero. This occurs if and only if every prime
|
||||
factor of den(x) is a factor of b.
|
||||
factor of den(x) is a factor of b.
|
||||
|
||||
EXAMPLE
|
||||
> print places(3), places(0.0123), places(3.70), places(1e-10), places(3/7)
|
||||
@@ -53,8 +53,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.3 $
|
||||
## @(#) $Id: places,v 29.3 2000/12/14 10:32:24 chongo Exp $
|
||||
## @(#) $Revision: 29.4 $
|
||||
## @(#) $Id: places,v 29.4 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/places,v $
|
||||
##
|
||||
## Under source code control: 1995/10/03 10:40:02
|
||||
|
@@ -25,7 +25,7 @@ DESCRIPTION
|
||||
|
||||
The following illustrates what happens if ctrl-C is hit 5 seconds
|
||||
after the first command:
|
||||
|
||||
|
||||
> print sleep(20)
|
||||
|
||||
[Abort level 1]
|
||||
@@ -58,8 +58,8 @@ SEE ALSO
|
||||
## received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
##
|
||||
## @(#) $Revision: 29.1 $
|
||||
## @(#) $Id: sleep,v 29.1 2000/12/14 10:31:45 chongo Exp $
|
||||
## @(#) $Revision: 29.2 $
|
||||
## @(#) $Id: sleep,v 29.2 2000/12/17 12:27:58 chongo Exp $
|
||||
## @(#) $Source: /usr/local/src/cmd/calc/help/RCS/sleep,v $
|
||||
##
|
||||
## Under source code control: 2000/12/14 01:33:00
|
||||
|
34
qfunc.c
34
qfunc.c
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.3 $
|
||||
* @(#) $Id: qfunc.c,v 29.3 2000/07/17 15:35:49 chongo Exp $
|
||||
* @(#) $Revision: 29.4 $
|
||||
* @(#) $Id: qfunc.c,v 29.4 2000/12/17 13:07:32 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/qfunc.c,v $
|
||||
*
|
||||
* Under source code control: 1990/02/15 01:48:20
|
||||
@@ -976,6 +976,7 @@ qbern(ZVALUE z)
|
||||
long n, i, k, m, nn, dd;
|
||||
NUMBER **p;
|
||||
NUMBER *s, *s1, *c, *c1, *t;
|
||||
size_t sz;
|
||||
|
||||
if (zisone(z))
|
||||
return qlink(&_qneghalf_);
|
||||
@@ -999,15 +1000,15 @@ qbern(ZVALUE z)
|
||||
|
||||
if (m >= B_allocnum) {
|
||||
k = (m/QALLOCNUM + 1) * QALLOCNUM;
|
||||
sz = k * sizeof(NUMBER *);
|
||||
if (sz < (size_t) k)
|
||||
return NULL;
|
||||
if (B_allocnum == 0)
|
||||
p = (NUMBER **) malloc(k * sizeof(NUMBER *));
|
||||
p = (NUMBER **) malloc(sz);
|
||||
else
|
||||
p = (NUMBER **) realloc(B_table,
|
||||
k * sizeof(NUMBER *));
|
||||
if (p == NULL) {
|
||||
math_error("Not enough memory for Bernoulli numbers");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
p = (NUMBER **) realloc(B_table, sz);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
B_allocnum = k;
|
||||
B_table = p;
|
||||
}
|
||||
@@ -1069,6 +1070,7 @@ qeuler(ZVALUE z)
|
||||
long i, k, m, n, nn, dd;
|
||||
NUMBER **p;
|
||||
NUMBER *s, *s1, *c, *c1, *t;
|
||||
size_t sz;
|
||||
|
||||
|
||||
if (ziszero(z))
|
||||
@@ -1081,11 +1083,15 @@ qeuler(ZVALUE z)
|
||||
m = (n >> 1) - 1;
|
||||
if (m < E_num)
|
||||
return qlink(E_table[m]);
|
||||
p = (NUMBER **) realloc(E_table, (m + 1) * sizeof(NUMBER *));
|
||||
if (p == NULL) {
|
||||
math_error("Unable to allocate memory for Euler numbers");
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
sz = (m + 1) * sizeof(NUMBER *);
|
||||
if (sz < (size_t) m + 1)
|
||||
return NULL;
|
||||
if (E_num)
|
||||
p = (NUMBER **) realloc(E_table, sz);
|
||||
else
|
||||
p = (NUMBER **) malloc(sz);
|
||||
if (p == NULL)
|
||||
return NULL;
|
||||
E_table = p;
|
||||
for (k = E_num; k <= m; k++) {
|
||||
nn = 2 * k + 2;
|
||||
|
@@ -17,8 +17,8 @@
|
||||
# received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
# 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# @(#) $Revision: 29.2 $
|
||||
# @(#) $Id: Makefile,v 29.2 2000/06/07 14:02:54 chongo Exp $
|
||||
# @(#) $Revision: 29.3 $
|
||||
# @(#) $Id: Makefile,v 29.3 2000/12/17 12:28:31 chongo Exp $
|
||||
# @(#) $Source: /usr/local/src/cmd/calc/sample/RCS/Makefile,v $
|
||||
#
|
||||
# Under source code control: 1997/04/19 22:46:49
|
||||
@@ -378,7 +378,10 @@ depend:
|
||||
fi; \
|
||||
done
|
||||
${Q}(cd ..; ${MAKE} hsrc)
|
||||
${Q}for i in `cd ..; ${MAKE} h_list`; do \
|
||||
${Q}for i in `cd ..; ${MAKE} h_list 2>&1 | \
|
||||
${SED} -e '/Entering directory/d' \
|
||||
-e '/Nothing to be done/d' \
|
||||
-e '/Leaving directory/d'`; do \
|
||||
tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
|
||||
echo "#if !defined($$tag)" > "skel/$$i"; \
|
||||
echo "#define $$tag" >> "skel/$$i"; \
|
||||
|
@@ -19,8 +19,8 @@
|
||||
* received a copy with calc; if not, write to Free Software Foundation, Inc.
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
|
||||
*
|
||||
* @(#) $Revision: 29.17 $
|
||||
* @(#) $Id: version.c,v 29.17 2000/12/15 14:58:20 chongo Exp $
|
||||
* @(#) $Revision: 29.18 $
|
||||
* @(#) $Id: version.c,v 29.18 2000/12/17 12:31:05 chongo Exp $
|
||||
* @(#) $Source: /usr/local/src/cmd/calc/RCS/version.c,v $
|
||||
*
|
||||
* Under source code control: 1990/05/22 11:00:58
|
||||
@@ -43,7 +43,7 @@ static char *program;
|
||||
#define MAJOR_VER 2 /* major version */
|
||||
#define MINOR_VER 11 /* minor version */
|
||||
#define MAJOR_PATCH 4 /* patch level or 0 if no patch */
|
||||
#define MINOR_PATCH "1" /* test number or empty string if no patch */
|
||||
#define MINOR_PATCH "2" /* test number or empty string if no patch */
|
||||
|
||||
/*
|
||||
* calc version constants
|
||||
|
Reference in New Issue
Block a user