Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
25 changes: 11 additions & 14 deletions deps/fast_float/Makefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
# Fallback to gcc/g++ when $CC or $CXX is not in $PATH.
# fast_float - C implementation for Redis
# This replaces the C++ version with a pure C implementation.

CC ?= gcc
CXX ?= g++

WARN=-Wall
WARN=-Wall -Wextra
OPT=-O3
STD=-std=c++11
DEFS=-DFASTFLOAT_ALLOWS_LEADING_PLUS

FASTFLOAT_CFLAGS=$(WARN) $(OPT) $(STD) $(DEFS) $(CFLAGS)
FASTFLOAT_LDFLAGS=$(LDFLAGS)
FAST_FLOAT_CFLAGS=$(WARN) $(OPT) $(CFLAGS)
FAST_FLOAT_LDFLAGS=$(LDFLAGS)

libfast_float: fast_float_strtod.o
$(AR) -r libfast_float.a fast_float_strtod.o
$(AR) rcs libfast_float.a fast_float_strtod.o

32bit: FASTFLOAT_CFLAGS += -m32
32bit: FASTFLOAT_LDFLAGS += -m32
32bit: FAST_FLOAT_CFLAGS += -m32
32bit: FAST_FLOAT_LDFLAGS += -m32
32bit: libfast_float

fast_float_strtod.o: fast_float_strtod.cpp
$(CXX) $(FASTFLOAT_CFLAGS) -c fast_float_strtod.cpp $(FASTFLOAT_LDFLAGS)
fast_float_strtod.o: fast_float_strtod.c fast_float_strtod.h
$(CC) $(FAST_FLOAT_CFLAGS) -c fast_float_strtod.c -o fast_float_strtod.o $(FAST_FLOAT_LDFLAGS)

clean:
rm -f *.o
rm -f *.a
rm -f *.h.gch
rm -rf *.dSYM
36 changes: 21 additions & 15 deletions deps/fast_float/README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
README for fast_float v6.1.4
fast_float_strtod - C Implementation
====================================

----------------------------------------------
This is a pure C implementation of fast string to double conversion,
originally based on the fast_float C++ library[1].

We're using the fast_float library[1] in our (compiled-in)
floating-point fast_float_strtod implementation for faster and more
portable parsing of 64 decimal strings.
The implementation was converted to C to remove the C++ dependency from
Redis. Only the functionality needed by Redis is implemented:

The single file fast_float.h is an amalgamation of the entire library,
which can be (re)generated with the amalgamate.py script (from the
fast_float repository) via the command
- Parsing of decimal floating-point strings
- Support for leading plus sign (+)
- Support for inf/infinity and nan special values
- Scientific notation (e/E exponent)

```
git clone https://github.com/fastfloat/fast_float
cd fast_float
git checkout v6.1.4
python3 ./script/amalgamate.py --license=MIT \
> $REDIS_SRC/deps/fast_float/fast_float.h
```
The algorithm uses:
1. Fast path (Clinger's algorithm) for numbers that can be exactly
represented: mantissa <= 2^53 and exponent in [-22, 22]
2. Fallback to standard strtod() for complex cases to ensure
correctly-rounded results

Original fast_float library:
https://github.com/fastfloat/fast_float
by Daniel Lemire and João Paulo Magalhaes

License: MIT (see fast_float_strtod.c for full license text)

[1]: https://github.com/fastfloat/fast_float
Loading
Loading