Skip to content

Instantly share code, notes, and snippets.

Created July 21, 2015 00:39
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
NaN double vs float testing
package com.databricks.unsafe.util.benchmark;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.runner.Runner;
import org.openjdk.jmh.runner.RunnerException;
import org.openjdk.jmh.runner.options.Options;
import org.openjdk.jmh.runner.options.OptionsBuilder;
public class NaNTesting {
public boolean doubleNaN() {
return Double.isNaN(Float.NaN);
public boolean floatNaN() {
return Float.isNaN(Float.NaN);
public static void main(String[] args) throws RunnerException {
Options opt = new OptionsBuilder()
new Runner(opt).run();
Benchmark Mode Cnt Score Error Units
NaNTesting.doubleNaN thrpt 4 470522065.357 ± 64048838.498 ops/s
NaNTesting.floatNaN thrpt 4 465024924.176 ± 66806183.042 ops/s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment