Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
6e1ea2a
Add bignum.h and port exactfloat to use it.
smcallis Sep 24, 2025
f84d63c
Rework Karatsuba and respond to PR comments.
smcallis Sep 24, 2025
20f683f
Address round 2 CR comments.
smcallis Sep 28, 2025
d05deac
Address PR Round 3 comments.
smcallis Sep 29, 2025
4552c91
Fix Karatsuba for highly asymmetric operand sizes.
smcallis Sep 29, 2025
df3de50
Remove assignment operator.
smcallis Sep 29, 2025
145c441
PR round 4 fixes.
smcallis Sep 30, 2025
bcf22c0
PR (Mega) round 5 changes.
smcallis Oct 3, 2025
eb02a46
PR (Mega) Round 5 more changes.
smcallis Oct 3, 2025
670e946
PR Round 7 changes.
smcallis Oct 4, 2025
8485aec
Cleanup util/math BUILD file and ensure clean compilation and run.
smcallis Oct 4, 2025
8b1cafb
Remove final usage of ssize_t.
smcallis Oct 4, 2025
08d1991
Add exactfloat_test to BUILD file.
smcallis Oct 4, 2025
ec5c313
Use int64_t instead of int for size casts out of an abundance of caut…
smcallis Oct 4, 2025
e7a4cb7
Split INT_MIN construction test case into a separate named case.
smcallis Oct 4, 2025
82d89d7
Fix typo in bignum.cc.
smcallis Oct 4, 2025
b363023
Add comment for the Numbers() function.
smcallis Oct 4, 2025
d3db3f6
Create tagged seed sequences for bignum tests and minor fixes.
smcallis Oct 5, 2025
906afdc
CR Round 7 fixes.
smcallis Oct 8, 2025
c118358
CR round 8 changes.
smcallis Oct 10, 2025
54508e3
Minor renaming and comment fixes.
smcallis Oct 11, 2025
0d6ccf4
Remove redundant borrow propagation loop.
smcallis Oct 11, 2025
50c9922
Revert .bazelrc changes.
smcallis Oct 22, 2025
83e5b3c
Minor formatting cleanup.
smcallis Oct 24, 2025
a54f63f
Revert to using find_package for OpenSSL.
smcallis Oct 24, 2025
7d40d30
Remove 0 - term when static_cast-ing INT_MIN to take absolute value.
smcallis Oct 24, 2025
eb90050
Make find_package(OpenSSL) test-only and minor fixups.
smcallis Oct 24, 2025
7c3dcd7
Minor spacing fixes and more comments on AddBigit and MulAddBigit.
smcallis Oct 25, 2025
7494306
Minor edits.
smcallis Oct 30, 2025
edfc034
Add SafeAbs to avoid UB when casting INT_MIN.
smcallis Oct 31, 2025
30ab250
Change is_normal calls to isnormal().
smcallis Dec 7, 2025
ee70a74
Remove old //s2//base:port dependency from exactfloat.
smcallis Dec 7, 2025
d46c2e9
CR round 9 minor changes.
smcallis Dec 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ add_definitions(-DABSL_MIN_LOG_LEVEL=1)
if (NOT TARGET absl::base)
find_package(absl REQUIRED)
endif()
find_package(OpenSSL REQUIRED)
# pthreads isn't used directly, but this is still required for std::thread.
find_package(Threads REQUIRED)

Expand Down Expand Up @@ -215,6 +214,7 @@ add_library(s2
src/s2/util/bits/bit-interleave.cc
src/s2/util/coding/coder.cc
src/s2/util/coding/varint.cc
src/s2/util/math/exactfloat/bignum.cc
src/s2/util/math/exactfloat/exactfloat.cc
src/s2/util/math/mathutil.cc
src/s2/util/units/length-units.cc)
Expand All @@ -230,7 +230,6 @@ endif()

target_link_libraries(
s2
${OPENSSL_LIBRARIES}
absl::absl_vlog_is_on
absl::base
absl::btree
Expand Down Expand Up @@ -459,7 +458,8 @@ if(S2_ENABLE_INSTALL)
src/s2/util/math/matrix3x3.h
src/s2/util/math/vector.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/math")
install(FILES src/s2/util/math/exactfloat/exactfloat.h
install(FILES src/s2/util/math/exactfloat/bignum.h
src/s2/util/math/exactfloat/exactfloat.h
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/s2/util/math/exactfloat")
install(FILES src/s2/util/units/length-units.h
src/s2/util/units/physical-units.h
Expand Down Expand Up @@ -489,6 +489,8 @@ if(S2_ENABLE_INSTALL)
endif() # S2_ENABLE_INSTALL

if (BUILD_TESTS)
find_package(OpenSSL REQUIRED)

if (NOT GOOGLETEST_ROOT)
message(FATAL_ERROR "BUILD_TESTS requires GOOGLETEST_ROOT")
endif()
Expand Down Expand Up @@ -620,6 +622,7 @@ if (BUILD_TESTS)
src/s2/s2wrapped_shape_test.cc
src/s2/sequence_lexicon_test.cc
src/s2/value_lexicon_test.cc
src/s2/util/math/exactfloat/bignum_test.cc
src/s2/util/math/exactfloat/exactfloat_test.cc
src/s2/util/math/exactfloat/exactfloat_underflow_test.cc)

Expand All @@ -630,6 +633,7 @@ if (BUILD_TESTS)
add_executable(${test} ${test_cc})
target_link_libraries(
${test}
${OPENSSL_CRYPTO_LIBRARIES}
s2testing s2
absl::base
absl::btree
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ This issue may require revision of boringssl or exactfloat.
* [Abseil](https://github.com/abseil/abseil-cpp) LTS
[`20250814`](https://github.com/abseil/abseil-cpp/releases/tag/20250814.1)
(standard library extensions). This exact version must be used.
* [OpenSSL](https://github.com/openssl/openssl) (for its bignum library)
* [googletest testing framework >= 1.10](https://github.com/google/googletest)
(to build tests and example programs, optional)

Expand Down Expand Up @@ -139,6 +138,13 @@ Disable building of shared libraries with `-DBUILD_SHARED_LIBS=OFF`.

Enable the python interface with `-DWITH_PYTHON=ON`.

# For Testing

If BUILD_TESTS is 'on' (the default), then OpenSSL must be available to build
some tests:

* [OpenSSL](https://github.com/openssl/openssl) (for its bignum library)

If OpenSSL is installed in a non-standard location set `OPENSSL_ROOT_DIR`
before running configure, for example on macOS:
```
Expand Down Expand Up @@ -218,7 +224,7 @@ python -m build

The resulting wheel will be in the `dist` directory.

> If OpenSSL is in a non-standard location make sure to set `OPENSSL_ROOT_DIR`;
> If OpenSSL is in a non-standard location make sure to set `OPENSSL_ROOT_DIR`;
> see above for more information.

## Other S2 implementations
Expand Down
28 changes: 26 additions & 2 deletions src/s2/util/math/exactfloat/BUILD
Original file line number Diff line number Diff line change
@@ -1,14 +1,37 @@
package(default_visibility = ["//visibility:public"])

cc_library(
name = "bignum",
srcs = ["bignum.cc"],
hdrs = ["bignum.h"],
visibility = ["//visibility:private"],
deps = [
"@abseil-cpp//absl/algorithm:container",
"@abseil-cpp//absl/container:inlined_vector",
"@abseil-cpp//absl/log:absl_check",
],
)

cc_library(
name = "exactfloat",
srcs = ["exactfloat.cc"],
hdrs = ["exactfloat.h"],
deps = [
":bignum",
"//s2/base:logging",
"@abseil-cpp//absl/log:log",
"@abseil-cpp//absl/log:absl_check",
],
)

cc_test(
name = "bignum_test",
srcs = ["bignum_test.cc"],
deps = [
":bignum",
"//:s2_testing_headers",
"@abseil-cpp//absl/log:log_streamer",
"@abseil-cpp//absl/random:bit_gen_ref",
"@boringssl//:crypto",
"@googletest//:gtest_main",
],
)

Expand All @@ -30,6 +53,7 @@ cc_test(
srcs = ["exactfloat_underflow_test.cc"],
deps = [
":exactfloat",
"@abseil-cpp//absl/random:random",
"@googletest//:gtest_main",
],
)
Loading
Loading