Avoid negative shift. (#42)

* Avoid negative shift.

When filling in fractional digits in a fixed representation we
might use all existing digits. When this happens, we can not look
at the next digit to see if we should round up.

Before this fix, we tried to shift by a negative amount to see if the
(non-existing) next bit was set to 1 (requiring the number to be rounded up).

Fixes #41.
2 files changed
tree: 60a4e3e447e1841c489779fcb0d72aa07406238a
  1. double-conversion/
  2. msvc/
  3. test/
  4. .gitignore
  5. AUTHORS
  6. BUILD
  7. Changelog
  8. CMakeLists.txt
  9. COPYING
  10. double-conversionBuildTreeSettings.cmake.in
  11. double-conversionConfig.cmake.in
  12. double-conversionConfigVersion.cmake.in
  13. LICENSE
  14. Makefile
  15. README.md
  16. SConstruct
  17. WORKSPACE
README.md

https://github.com/google/double-conversion

This project (double-conversion) provides binary-decimal and decimal-binary routines for IEEE doubles.

The library consists of efficient conversion routines that have been extracted from the V8 JavaScript engine. The code has been refactored and improved so that it can be used more easily in other projects.

There is extensive documentation in double-conversion/double-conversion.h. Other examples can be found in test/cctest/test-conversions.cc.

Building

This library can be built with scons or cmake. The checked-in Makefile simply forwards to scons, and provides a shortcut to run all tests:

make
make test

Scons

The easiest way to install this library is to use scons. It builds the static and shared library, and is set up to install those at the correct locations:

scons install

Use the DESTDIR option to change the target directory:

scons DESTDIR=alternative_directory install

Cmake

To use cmake run cmake . in the root directory. This overwrites the existing Makefile.

Use -DBUILD_SHARED_LIBS=ON to enable the compilation of shared libraries. Note that this disables static libraries. There is currently no way to build both libraries at the same time with cmake.

Use -DBUILD_TESTING=ON to build the test executable.

cmake . -DBUILD_TESTING=ON
make
test/cctest/cctest --list | tr -d '<' | xargs test/cctest/cctest