+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse-cdt version="2.0"?>
-
-<cdtproject id="org.eclipse.cdt.make.core.make">
-<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
-<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>
-<data>
-<item id="scannerConfiguration">
-<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="true" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="g++" useDefault="true"/>
-<parser enabled="true"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
-<buildOutputProvider>
-<openAction enabled="false" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="makefileGenerator">
-<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
-<parser enabled="false"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="false" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="false"/>
-</scannerInfoProvider>
-</profile>
-<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
-<buildOutputProvider>
-<openAction enabled="false" filePath=""/>
-<parser enabled="true"/>
-</buildOutputProvider>
-<scannerInfoProvider id="specsFile">
-<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
-<parser enabled="false"/>
-</scannerInfoProvider>
-</profile>
-</item>
-<item id="org.eclipse.cdt.core.pathentry">
-<pathentry kind="src" path=""/>
-<pathentry kind="out" path=""/>
-<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
-</item>
-</data>
-</cdtproject>
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>bigint</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.cdt.make.core.makeBuilder</name>
- <arguments>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.arguments</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.core.errorOutputParser</key>
- <value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.environment</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableFullBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.target.inc</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.location</key>
- <value></value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.target.clean</key>
- <value>clean</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.command</key>
- <value>make</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.append_environment</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.target.full</key>
- <value>clean all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
- <value>true</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.build.target.auto</key>
- <value>all</value>
- </dictionary>
- <dictionary>
- <key>org.eclipse.cdt.make.core.stopOnError</key>
- <value>false</value>
- </dictionary>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.cdt.core.cnature</nature>
- <nature>org.eclipse.cdt.make.core.makeNature</nature>
- <nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
- <nature>org.eclipse.cdt.core.ccnature</nature>
- </natures>
-</projectDescription>
}
if (carry) {
// Matt fixed a bug 2004.12.24: next 2 lines used to say allocateAndCopy(len + 1)
+ // Matt fixed another bug 2006.04.24:
+ // old number only has len blocks, so copy before increasing length
+ allocateAndCopy(len + 1);
len++;
- allocateAndCopy(len);
blk[i] = 1;
}
}
// Compares this to x like Perl's <=>
CmpRes compareTo(const BigUnsigned &x) const;
// Normal comparison operators
- NumberlikeArray<Blk>::operator ==; // (NlA) The body used to be `{ return compareTo(x) == equal; }'. For performance reasons we use NumberlikeArray code that only worries about (in)equality and doesn't waste time determining which is bigger
- NumberlikeArray<Blk>::operator !=; // (NlA) Ditto.
+ // Bug fixed 2006.04.24: Only we, not the user, can pass a BigUnsigned off as a
+ // NumberlikeArray, so we have to wrap == and !=.
+ bool operator ==(const BigUnsigned &x) const {
+ return NumberlikeArray<Blk>::operator ==(x);
+ }
+ bool operator !=(const BigUnsigned &x) const {
+ return NumberlikeArray<Blk>::operator !=(x);
+ }
bool operator < (const BigUnsigned &x) const { return compareTo(x) == less ; }
bool operator <=(const BigUnsigned &x) const { return compareTo(x) != greater; }
bool operator >=(const BigUnsigned &x) const { return compareTo(x) != less ; }
==========
These entries tell you what was added, fixed, or improved in each version as compared to the previous one. In case you haven't noticed, a version number roughly corresponds to the release date of that version in `YYYY.MM.DD[.N]' format, where `.N' goes `.2', `.3', etc. if there are multiple versions on the same day.
+2006.04.24
+----------
+Two bug fixes: BigUnsigned "++x" no longer segfaults when x grows in length, and BigUnsigned == and != are now redeclared so as to be usable. I redid the Makefile: I removed the *.tag mechanism and hard-coded the library's header dependencies, I added comments, and I made the Makefile more useful for building one's own programs instead of just the sample.
+
2006.02.26
----------
A few tweaks in preparation for a group to distribute the library. The project Web site has moved; I updated the references. I fixed a typo and added a missing function in NumberlikeArray.hh. I'm using Eclipse now, so you get Eclipse project files.
# http://hashproduct.metaesthetics.net/bigint/
#
-# The implicit rules we need
-%.tag : %
- touch $@
+# Mention default target.
+all :
+
+# Implicit rule to compile C++ files. Modify to your taste.
%.o : %.cc
g++ -c -O -Wall -Wextra -pedantic $<
-# Default target
-all : library sample
+# Components of the library.
+library-objects = BigUnsigned.o BigInteger.o BigUnsignedInABase.o BigIntegerUtils.o
+library-headers = NumberlikeArray.hh BigUnsigned.hh BigUnsignedInABase.hh BigInteger.hh BigIntegerLibrary.hh
+
+# To ``make the library'', make all its objects using the implicit rule.
+library : $(library-objects)
+
+# Extra dependencies from `#include'.
+BigUnsigned.o : NumberlikeArray.hh BigUnsigned.hh
+BigInteger.o : NumberlikeArray.hh BigUnsigned.hh BigInteger.hh
+BigUnsignedInABase.o : NumberlikeArray.hh BigUnsigned.hh BigUnsignedInABase.hh
+BigIntegerUtils.o : NumberlikeArray.hh BigUnsigned.hh BigUnsignedInABase.hh BigInteger.hh
-library : BigUnsigned.o BigInteger.o BigUnsignedInABase.o BigIntegerUtils.o
+# The rules below build a program that uses the library. They are preset to
+# build ``sample'' from ``sample.cc''. You can change the name(s) of the
+# source file(s) and program file to build your own program, or you can write
+# your own Makefile.
-# Extra dependencies from `#include'
-BigUnsigned.hh.tag : NumberlikeArray.hh.tag
-BigUnsigned.o : BigUnsigned.hh.tag
-BigInteger.hh.tag : BigUnsigned.hh.tag
-BigInteger.o : BigInteger.hh.tag
-BigUnsignedInABase.hh.tag : BigUnsigned.hh.tag
-BigUnsignedInABase.o : BigUnsignedInABase.hh.tag
-BigIntegerUtils.hh.tag : BigInteger.hh.tag
-BigIntegerUtils.o : BigIntegerUtils.hh.tag
+# Components of the program.
+program = sample
+program-objects = sample.o
-# sample program
-sample : library sample.cc
- g++ -osample *.o sample.cc
+# Conservatively assume all the program source files depend on all the library
+# headers. You can change this if it is not the case.
+$(program-objects) : $(library-headers)
+# How to link the program. The implicit rule covers individual objects.
+$(program) : $(program-objects) $(library-objects)
+ g++ $(program-objects) $(library-objects) -o $(program)
+
+# Delete all generated files we know about.
clean :
- rm -f *.tag *.o sample
+ rm -f $(library-objects) $(program-objects) $(program)
-# The `.tag' mechanism allows for proper recompilation when a header file
-# changes, considering that some header files may include others.
-#
-# If a header file X includes other header
-# files Y and Z, we create a file X.tag that depends
-# on X, Y.tag, and Z.tag. Other headers that include X should
-# depend on X.tag.
-#
-# Suppose Y is subsequently changed. X doesn't get ``recompiled'',
-# but anything that includes X should be recompiled. Well, Y.tag becomes
-# out-of-date, so X.tag becomes out-of-date, so anything depending on X.tag
-# (that is, anything including X) becomes out-of-date. Magic!
-#
-# In this system, the tag files are empty files used only for their
-# timestamps. If one wished to use precompiled headers, one could use
-# ``.gch'' files exactly how ``.tag'' files are used now, except that
-# their contents would be meaningful.
-#
-# However, the same sort of ``deadly diamond'' problem that surfaces with
-# multiple inheritance also applies to precompiled headers. The ``#ifndef''
-# mechanism that prevents multiple inclusion doesn't work when headers are
-# compiled independently in a hierarchical structure, since the second
-# inclusion of a file won't even know there was a first inclusion. For
-# this reason, I just use ``.tag''s.
+# I removed the *.tag dependency tracking system because it had few advantages
+# over manually entering all the dependencies. If there were a portable,
+# reliable dependency tracking system, I'd use it, but I know of no such;
+# cons and depcomp are almost good enough.
+
+# Come back and define default target.
+all : library $(program)