The easiest way to use FastFloat is downloading the pre-built JAR with integrated native library:
Download the latest release: Releases Page
# Download JAR with integrated DLL/SO/DYLIB
wget https://github.com/andrestubbe/FastFloat/releases/download/v1.2.0/fastfloat-1.2.0.jar
# Or download JAR + separate native library
wget https://github.com/andrestubbe/FastFloat/releases/download/v1.2.0/fastfloat-1.2.0.jar
wget https://github.com/andrestubbe/FastFloat/releases/download/v1.2.0/fastfloat.dll # Windows
wget https://github.com/andrestubbe/FastFloat/releases/download/v1.2.0/libfastfloat.so # Linux
wget https://github.com/andrestubbe/FastFloat/releases/download/v1.2.0/libfastfloat.dylib # macOS<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>fastfloat</artifactId>
<version>v1.2.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:fastfloat:v1.2.0'
}- JDK 17+
- Maven 3.9+
- Windows: Visual Studio 2019+ or Build Tools
- Linux: GCC 9+ or Clang 10+
- macOS: Xcode Command Line Tools
compile.bat
mvn clean packagechmod +x compile.sh
./compile.sh
mvn clean packageThe build script auto-detects CPU features (AVX2, AVX-512, FMA3) and compiles with optimal flags (-O3 -march=native -ffast-math).
For building native libraries for multiple platforms:
# Windows (MSVC)
compile.bat
# Linux (GCC/Clang)
./compile.sh
# macOS (Clang)
./compile.shThe native library will be placed in build/ (Windows: fastfloat.dll, Linux: libfastfloat.so, macOS: libfastfloat.dylib).
cl /O2 /arch:AVX2 /fp:fast /GL /LTCG fastfloat.cppFlags explained:
/O2- Maximum optimization/arch:AVX2- Enable AVX2 instructions/fp:fast- Fast floating-point model (20-30% speedup)/GL- Whole program optimization/LTCG- Link-time code generation
g++ -O3 -march=native -ffast-math -fPIC -shared -o libfastfloat.so fastfloat.cppFlags explained:
-O3- Maximum optimization-march=native- Optimize for host CPU-ffast-math- Aggressive floating-point optimizations-fPIC- Position-independent code
cd examples/00-basic-usage
mvn compile exec:javaIf you get UnsatisfiedLinkError, the native library was not found:
- Check that the DLL/so/dylib exists in
build/ - On Windows, ensure the DLL is in PATH or copy to
C:\Windows\System32 - On Linux/macOS, set
LD_LIBRARY_PATHorDYLD_LIBRARY_PATH
If AVX2/AVX-512 detection fails, you can force specific optimizations:
# Force SSE4.2 only (older CPUs)
./compile.sh --sse42
# Force AVX2
./compile.sh --avx2
# Force AVX-512
./compile.sh --avx512For optimal performance across different CPUs, build multiple binaries:
# Build all variants
./compile.sh --multi
# This creates:
# - build/libfastfloat_sse42.so (baseline)
# - build/libfastfloat_avx2.so (AVX2 optimized)
# - build/libfastfloat_avx512.so (AVX-512 optimized)
# The library auto-selects the best version at runtime based on CPUID