⚡ 5.1× faster than standard Java's Float.parseFloat / Double.parseDouble. Zero GC. SIMD accelerated. Ryu algorithm formatting.
FastFloat provides high-performance native float and double parsing and formatting for Java, replacing slow string allocations with native AVX2 SIMD vector operations.
import fastfloat.FastFloat;
import java.nio.ByteBuffer;
public class Demo {
public static void main(String[] args) {
// 1. 5.1× faster parsing — zero allocations
float f = FastFloat.parseFloat("3.14159");
double d = FastFloat.parseDouble("2.718281828459045");
// 2. Zero-GC fast path (no exceptions, packed error/value result)
long packed = FastFloat.parseFloatZeroGC("3.14159");
if (FastFloat.unpackError(packed) == FastFloat.ERR_OK) {
float value = FastFloat.unpackFloat(packed);
}
// 3. Ryu high-speed float/double formatting
String formatted = FastFloat.toString(f);
}
}- Why FastFloat?
- Key Features
- Real-World Use Cases
- Performance Benchmarks
- Architecture Overview
- API Quick Reference
- Technical Demos & Benchmarks
- Installation
- Documentation
- Platform Support
- License
- Related Projects
Standard Java Float.parseFloat() and Double.parseDouble() rely on complex, slow string allocations and Exception-throwing error handling. FastFloat addresses this by:
- SIMD Vectorization — Uses native C++ AVX2 vector instructions for multi-digit parallel parsing.
- Ryu Formatting — Implements the Ryu algorithm for ultra-fast, shortest-representation float-to-string conversion.
- Zero-GC Fast Path — Bit-packed
parseFloatZeroGC()eliminates JVM Garbage Collection overhead completely.
| Feature | Float.parseFloat / Double | fast_float (C++ / JNI wrapper) | FastFloat |
|---|---|---|---|
| Parsing Throughput | ~4.23M ops/s | ~12-15M ops/s | 21.65M+ ops/s (5.1× speedup) |
| Error Handling | Heavy NumberFormatException |
JNI boundary checks | Zero-GC bit-packed primitive long |
| Direct Buffer Ingestion | Must convert to String first |
Partial buffer support | Direct off-heap ByteBuffer parsing |
| Formatting Algorithm | Slow Grisu / Java Double.toString | Standard snprintf / Grisu | Ryu shortest-representation engine |
- ⚡ Native AVX2 SIMD Acceleration — Leverages 256-bit AVX2 vector registers for ultra-fast digit scanning and conversion.
- 🚀 5.1× Throughput Speedup — Reaches over 21.6 Million parsing operations per second on standard desktop hardware.
- 🧠 Zero-GC Bit-Packed API — Returns packed error status and float values inside a primitive
longto prevent heap allocations. - 🌐 Ryu Algorithm Formatting — Generates exact shortest string representations of floats and doubles with minimum latency.
- 📦 Direct ByteBuffer Ingestion — Parses floats directly from off-heap
ByteBufferregions without converting tojava.lang.String.
- 📊 High-Frequency Financial Data Feed: Parse millions of stock quotes, ticks, and floating-point trade prices per second.
- 🤖 Machine Learning Feature Ingestion: Accelerate CSV and JSON float feature parsing before feeding tensors into ONNX models.
- 📡 IoT & Telemetry Sensor Streams: Process high-rate sensor readings directly from DMA native memory buffers without GC pauses.
- 🎮 Game Engine Physics & Graphics: Deserialize 3D vertex positions and transformation matrices in real-time game loops.
In the official JMH Benchmark, FastFloat measured parsing throughput against standard Float.parseFloat():
Benchmark Mode Cnt Score Error Units
Benchmark.benchmarkFastFloatParse thrpt 2 21656206.611 ops/s
Benchmark.benchmarkJavaFloatParse thrpt 2 4236773.465 ops/s
21.6 Million Operations per Second (5.1× Speedup):
FastFloatparses floating point strings at 21.65 Million ops/s, achieving a 5.1× hardware speedup over Java's standardFloat.parseFloat()(4.23 Million ops/s).
FastFloat (This Library — The Native Math Engine)
Provides SIMD-accelerated float/double parsing and Ryu formatting for Java.
FastSIMD (Hardware Acceleration Engine)
Provides cross-platform hardware SIMD primitives (_mm256_cmpeq_epi8, _mm256_fmadd_ps).
FastJSON (Zero-GC JSON Parser)
Integrates FastFloat for sub-microsecond JSON numerical field extraction.
| Method | Description | Path |
|---|---|---|
parseFloat(String) |
Standard 5.1× faster float parsing. | Reference 📖 |
parseFloatZeroGC(String) |
Bit-packed zero-allocation float parsing. | Reference 📖 |
toString(float) |
High-speed Ryu float formatting. | Reference 📖 |
Run standalone verification demos or execute JMH throughput benchmarks:
| Type | Target / Launcher | Source File | Description |
|---|---|---|---|
| Interactive Demo | run-demo.bat |
Demo.java |
Live float/double parsing, zero-GC bit-packed unpacking, and Ryu formatting |
| Throughput Benchmark | run-benchmark.bat |
Benchmark.java |
JMH benchmark comparing SIMD FastFloat.parseFloat against Float.parseFloat |
Add the JitPack repository and the complete dependency stack to your pom.xml:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- FastFloat Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastFloat</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastSIMD Hardware Vector Acceleration Engine -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastSIMD</artifactId>
<version>0.1.3</version>
</dependency>
<!-- FastMemory Aligned Allocator -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastMemory</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastPointer Address Wrapper -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastPointer</artifactId>
<version>0.1.1</version>
</dependency>
<!-- FastCore Native Loader -->
<dependency>
<groupId>com.github.andrestubbe</groupId>
<artifactId>FastCore</artifactId>
<version>0.1.0</version>
</dependency>
</dependencies>repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
implementation 'com.github.andrestubbe:FastFloat:0.1.1'
implementation 'com.github.andrestubbe:FastSIMD:0.1.3'
implementation 'com.github.andrestubbe:FastMemory:0.1.1'
implementation 'com.github.andrestubbe:FastPointer:0.1.1'
implementation 'com.github.andrestubbe:FastCore:0.1.0'
}Download the required JARs directly to add them to your classpath:
- ⚡ FastFloat-0.1.1.jar (The Core Library)
- 🚀 FastSIMD-0.1.3.jar (Hardware Vector Acceleration Engine)
- 💾 FastMemory-0.1.1.jar (32-Byte Aligned Allocator)
- 📍 FastPointer-0.1.1.jar (Primitive Address Pointer)
- ⚙️ fastcore-0.1.0.jar (Mandatory Native Loader)
Important
All JARs must be included in your classpath for the native SIMD JNI bindings to function correctly.
- CHANGELOG.md: Version history and release notes.
- COMPILE.md: Full compilation guide (MSVC C++17 build chain + JNI Setup).
- REFERENCE.md: Full API contracts and routing logic.
- PHILOSOPHY.md: Zero Context-Loss and zero-GC philosophy.
- ROADMAP.md: Future development goals.
| Platform | Status |
|---|---|
| Windows 10/11 (x64) | ✅ Fully Supported |
| Linux | 🔄 Planned |
| macOS | 🔄 Planned |
MIT License — See LICENSE file for details.
- FastMath — SIMD and GPU vector math functions
- FastJSON — High-speed SIMD JSON parser
- FastBytes — AVX2 byte array operations
- FastCore — Native JNI loader for FastJava libraries
Part of the FastJava Ecosystem — Making the JVM faster. Small package. Maximum speed. Zero bloat. ⚡
