Index: boot/Makefile.common
===================================================================
--- boot/Makefile.common	(revision ace1bca41468e8c2409a37c799088907b37e6366)
+++ boot/Makefile.common	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -244,4 +244,5 @@
 	$(USPACE_PATH)/lib/sif/test-libsif \
 	$(USPACE_PATH)/lib/uri/test-liburi \
+	$(USPACE_PATH)/lib/math/test-libmath \
 	$(USPACE_PATH)/drv/bus/usb/xhci/test-xhci \
 	$(USPACE_PATH)/app/bdsh/test-bdsh \
Index: uspace/lib/c/include/fenv.h
===================================================================
--- uspace/lib/c/include/fenv.h	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
+++ uspace/lib/c/include/fenv.h	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2018 CZ.NIC, z.s.p.o.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _FENV_H
+#define _FENV_H
+
+// TODO
+
+#define FE_TOWARDZERO  0
+#define FE_TONEAREST   1
+#define FE_UPWARD      2
+#define FE_DOWNWARD    3
+
+#define fegetround() FE_TONEAREST
+
+#endif
+
Index: uspace/lib/c/include/float.h
===================================================================
--- uspace/lib/c/include/float.h	(revision ace1bca41468e8c2409a37c799088907b37e6366)
+++ uspace/lib/c/include/float.h	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -32,4 +32,8 @@
 // FIXME: <float.h> is freestanding. Just include the compiler-provided file.
 
+#define FLT_MIN __FLT_MIN__
+#define FLT_DENORM_MIN __FLT_DENORM_MIN__
+#define FLT_EPSILON __FLT_EPSILON__
+
 #define FLT_MANT_DIG  __FLT_MANT_DIG__
 #define DBL_MANT_DIG  __DBL_MANT_DIG__
Index: uspace/lib/c/include/math.h
===================================================================
--- uspace/lib/c/include/math.h	(revision ace1bca41468e8c2409a37c799088907b37e6366)
+++ uspace/lib/c/include/math.h	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -312,4 +312,8 @@
 #define copysignl __builtin_copysignl
 
+#define nextafter __builtin_nextafter
+#define nextafterf __builtin_nextafterf
+#define nextafterl __builtin_nextafterl
+
 #endif
 
Index: uspace/lib/math/Makefile
===================================================================
--- uspace/lib/math/Makefile	(revision ace1bca41468e8c2409a37c799088907b37e6366)
+++ uspace/lib/math/Makefile	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -39,7 +39,12 @@
 	generic/fabs.c \
 	generic/fmod.c \
+	generic/nearbyint.c \
 	generic/round.c \
 	generic/trig.c \
 	generic/trunc.c
 
+TEST_SOURCES = \
+	test/rounding.c \
+	test/main.c
+
 include $(USPACE_PREFIX)/Makefile.common
Index: uspace/lib/math/generic/nearbyint.c
===================================================================
--- uspace/lib/math/generic/nearbyint.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
+++ uspace/lib/math/generic/nearbyint.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -0,0 +1,185 @@
+/*
+ * Copyright (c) 2018 CZ.NIC, z.s.p.o.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup libmath
+ * @{
+ */
+/** @file
+ */
+
+#include <assert.h>
+#include <math.h>
+#include <fenv.h>
+#include <float.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+static float _roundf_even(float val)
+{
+	assert(!signbit(val));
+
+	/* Get some special cases out of the way first. */
+
+	if (islessequal(val, 0.5f))
+		return 0.0f;
+
+	if (isless(val, 1.5f))
+		return 1.0f;
+
+	if (islessequal(val, 2.5f))
+		return 2.0f;
+
+	const int exp_bias = FLT_MAX_EXP - 1;
+	const int mant_bits = FLT_MANT_DIG - 1;
+	const uint32_t mant_mask = (UINT32_C(1) << mant_bits) - 1;
+
+	union {
+		float f;
+		uint32_t i;
+	} u = { .f = val };
+
+	int exp = (u.i >> mant_bits) - exp_bias;
+	assert(exp > 0);
+
+	/* Mantissa has no fractional places. */
+	if (exp >= mant_bits)
+		return val;
+
+	/* Check whether we are rounding up or down. */
+	uint32_t first = (UINT32_C(1) << (mant_bits - exp));
+	uint32_t midpoint = first >> 1;
+	uint32_t frac = u.i & (mant_mask >> exp);
+
+	bool up;
+	if (frac == midpoint) {
+		up = (u.i & first);
+	} else {
+		up = (frac > midpoint);
+	}
+
+	u.i &= ~(mant_mask >> exp);
+	if (up) {
+		u.i += first;
+	}
+	return copysignf(u.f, val);
+}
+
+static float _round_even(float val)
+{
+	assert(!signbit(val));
+
+	/* Get some special cases out of the way first. */
+
+	if (islessequal(val, 0.5))
+		return 0.0;
+
+	if (isless(val, 1.5))
+		return 1.0;
+
+	if (islessequal(val, 2.5))
+		return 2.0;
+
+	const int exp_bias = DBL_MAX_EXP - 1;
+	const int mant_bits = DBL_MANT_DIG - 1;
+	const uint64_t mant_mask = (UINT64_C(1) << mant_bits) - 1;
+
+	union {
+		double f;
+		uint64_t i;
+	} u = { .f = val };
+
+	int exp = (u.i >> mant_bits) - exp_bias;
+	assert(exp > 0);
+
+	/* Mantissa has no fractional places. */
+	if (exp >= mant_bits)
+		return val;
+
+	/* Check whether we are rounding up or down. */
+	uint64_t first = (UINT64_C(1) << (mant_bits - exp));
+	uint64_t midpoint = first >> 1;
+	uint64_t frac = u.i & (mant_mask >> exp);
+
+	bool up;
+	if (frac == midpoint) {
+		up = (u.i & first);
+	} else {
+		up = (frac > midpoint);
+	}
+
+	u.i &= ~(mant_mask >> exp);
+	if (up) {
+		u.i += first;
+	}
+	return copysignf(u.f, val);
+}
+
+/**
+ * Rounds its argument to the nearest integer value in floating-point format,
+ * using the current rounding direction and without raising the inexact
+ * floating-point exception.
+ */
+float nearbyintf(float val)
+{
+	switch (fegetround()) {
+	case FE_DOWNWARD:
+		return floorf(val);
+	case FE_UPWARD:
+		return ceilf(val);
+	case FE_TOWARDZERO:
+		return truncf(val);
+	case FE_TONEAREST:
+		return copysignf(_roundf_even(fabsf(val)), val);
+	}
+
+	assert(false);
+}
+
+/**
+ * Rounds its argument to the nearest integer value in floating-point format,
+ * using the current rounding direction and without raising the inexact
+ * floating-point exception.
+ */
+double nearbyint(double val)
+{
+	switch (fegetround()) {
+	case FE_DOWNWARD:
+		return floor(val);
+	case FE_UPWARD:
+		return ceil(val);
+	case FE_TOWARDZERO:
+		return trunc(val);
+	case FE_TONEAREST:
+		return copysign(_round_even(fabs(val)), val);
+	}
+
+	assert(false);
+}
+
+/** @}
+ */
Index: uspace/lib/math/generic/round.c
===================================================================
--- uspace/lib/math/generic/round.c	(revision ace1bca41468e8c2409a37c799088907b37e6366)
+++ uspace/lib/math/generic/round.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -45,8 +45,4 @@
 float roundf(float val)
 {
-	/* If the input is a nan, return a canonical nan. */
-	if (isnan(val))
-		return __builtin_nanf("");
-
 	const int exp_bias = FLT_MAX_EXP - 1;
 	const int mant_bits = FLT_MANT_DIG - 1;
@@ -78,8 +74,4 @@
 double round(double val)
 {
-	/* If the input is a nan, return a canonical nan. */
-	if (isnan(val))
-		return __builtin_nan("");
-
 	const int exp_bias = DBL_MAX_EXP - 1;
 	const int mant_bits = DBL_MANT_DIG - 1;
Index: uspace/lib/math/generic/trunc.c
===================================================================
--- uspace/lib/math/generic/trunc.c	(revision ace1bca41468e8c2409a37c799088907b37e6366)
+++ uspace/lib/math/generic/trunc.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -55,8 +55,4 @@
 float truncf(float val)
 {
-	/* If the input is a nan, return a canonical nan. */
-	if (isnan(val))
-		return __builtin_nanf("");
-
 	const int exp_bias = FLT_MAX_EXP - 1;
 	const int mant_bits = FLT_MANT_DIG - 1;
@@ -99,8 +95,4 @@
 double trunc(double val)
 {
-	/* If the input is a nan, return a canonical nan. */
-	if (isnan(val))
-		return __builtin_nan("");
-
 	const int exp_bias = DBL_MAX_EXP - 1;
 	const int mant_bits = DBL_MANT_DIG - 1;
Index: uspace/lib/math/test/main.c
===================================================================
--- uspace/lib/math/test/main.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
+++ uspace/lib/math/test/main.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2014 Vojtech Horky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdio.h>
+#include <pcut/pcut.h>
+
+PCUT_INIT;
+
+PCUT_IMPORT(rounding);
+
+PCUT_MAIN();
+
Index: uspace/lib/math/test/rounding.c
===================================================================
--- uspace/lib/math/test/rounding.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
+++ uspace/lib/math/test/rounding.c	(revision 3b814c3abc3648c4a203827043d29fb02be2aad2)
@@ -0,0 +1,1207 @@
+/*
+ * Copyright (c) 2018 CZ.NIC, z.s.p.o.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <pcut/pcut.h>
+#include <math.h>
+#include <inttypes.h>
+
+PCUT_INIT;
+
+PCUT_TEST_SUITE(rounding);
+
+static inline uint32_t fint(float x) {
+	union {
+		float f;
+		uint32_t i;
+	} u = { .f = x };
+	return u.i;
+}
+
+static inline uint64_t dint(double x) {
+	union {
+		double f;
+		uint64_t i;
+	} u = { .f = x };
+	return u.i;
+}
+
+#define assert_float_equals(x, y) PCUT_ASSERT_EQUALS(fint(x), fint(y))
+#define assert_double_equals(x, y) PCUT_ASSERT_EQUALS(dint(x), dint(y))
+
+#define FLOAT_CASES 200
+#define DOUBLE_CASES 0
+
+
+static float float_arguments[FLOAT_CASES] = {
+	HUGE_VALF,
+	-HUGE_VALF,
+	__builtin_nanf(""),
+	-__builtin_nanf(""),
+	__builtin_nanf("0xdeadbe"),
+	-__builtin_nanf("0xdeadbe"),
+
+	0x0.000000p0f,       /* zero */
+	0x0.000002p-126f,    /* smallest denormal > 0 */
+	0x1.000000p-126f,    /* smallest normal > 0 */
+	0x1.fffffep-2f,      /* largest < 0.5 */
+	0x1.000000p-1f,      /* 0.5 */
+	0x1.000002p-1f,      /* smallest > 0.5 */
+	0x1.fffffep-1f,      /* largest < 1 */
+	0x1.000000p0f,       /* 1 */
+	0x1.000002p0f,       /* smallest > 1 */
+	0x1.7ffffep0f,       /* largest < 1.5 */
+	0x1.800000p0f,       /* 1.5 */
+	0x1.800002p0f,       /* smallest > 1.5 */
+	0x1.fffffep0f,       /* largest < 2 */
+	0x1.000000p1f,       /* 2 */
+	0x1.000002p1f,       /* smallest > 2 */
+	0x1.3ffffep1f,       /* largest < 2.5 */
+	0x1.400000p1f,       /* 2.5 */
+	0x1.400002p1f,       /* smallest > 2.5 */
+	0x1.7ffffep1f,       /* largest < 3 */
+	0x1.800000p1f,       /* 3 */
+	0x1.800002p1f,       /* smallest > 3 */
+	0x1.bffffep1f,       /* largest < 3.5 */
+	0x1.c00000p1f,       /* 3.5 */
+	0x1.c00002p1f,       /* smallest > 3.5 */
+	0x1.fffffep1f,       /* largest < 4 */
+	0x1.000000p2f,       /* 4 */
+	0x1.000002p2f,       /* smallest > 4 */
+
+	0x1.ffffe0p20f,      /* 2^21 - 2 */
+	0x1.ffffe2p20f,      /* 2^21 - 1.875 */
+	0x1.ffffe4p20f,      /* 2^21 - 1.75 */
+	0x1.ffffe6p20f,      /* 2^21 - 1.625 */
+	0x1.ffffe8p20f,      /* 2^21 - 1.5 */
+	0x1.ffffeap20f,      /* 2^21 - 1.375 */
+	0x1.ffffecp20f,      /* 2^21 - 1.25 */
+	0x1.ffffeep20f,      /* 2^21 - 1.125 */
+	0x1.fffff0p20f,      /* 2^21 - 1 */
+	0x1.fffff2p20f,      /* 2^21 - 0.875 */
+	0x1.fffff4p20f,      /* 2^21 - 0.75 */
+	0x1.fffff6p20f,      /* 2^21 - 0.625 */
+	0x1.fffff8p20f,      /* 2^21 - 0.5 */
+	0x1.fffffap20f,      /* 2^21 - 0.375 */
+	0x1.fffffcp20f,      /* 2^21 - 0.25 */
+	0x1.fffffep20f,      /* 2^21 - 0.125 */
+	0x1.000000p21f,      /* 2^21 */
+	0x1.000002p21f,      /* 2^21 + 0.25 */
+	0x1.000004p21f,      /* 2^21 + 0.5 */
+	0x1.000006p21f,      /* 2^21 + 0.75 */
+	0x1.000008p21f,      /* 2^21 + 1 */
+	0x1.00000ap21f,      /* 2^21 + 1.25 */
+	0x1.00000cp21f,      /* 2^21 + 1.5 */
+	0x1.00000ep21f,      /* 2^21 + 1.75 */
+	0x1.000010p21f,      /* 2^21 + 2 */
+
+	0x1.fffff0p21f,      /* 2^22 - 2 */
+	0x1.fffff2p21f,      /* 2^22 - 1.75 */
+	0x1.fffff4p21f,      /* 2^22 - 1.5 */
+	0x1.fffff6p21f,      /* 2^22 - 1.25 */
+	0x1.fffff8p21f,      /* 2^22 - 1 */
+	0x1.fffffap21f,      /* 2^22 - 0.75 */
+	0x1.fffffcp21f,      /* 2^22 - 0.5 */
+	0x1.fffffep21f,      /* 2^22 - 0.25 */
+	0x1.000000p22f,      /* 2^22 */
+	0x1.000002p22f,      /* 2^22 + 0.5 */
+	0x1.000004p22f,      /* 2^22 + 1 */
+	0x1.000006p22f,      /* 2^22 + 1.5 */
+	0x1.000008p22f,      /* 2^22 + 2 */
+
+	0x1.fffff0p22f,      /* 2^23 - 4 */
+	0x1.fffff2p22f,      /* 2^23 - 3.5 */
+	0x1.fffff4p22f,      /* 2^23 - 3 */
+	0x1.fffff6p22f,      /* 2^23 - 2.5 */
+	0x1.fffff8p22f,      /* 2^23 - 2 */
+	0x1.fffffap22f,      /* 2^23 - 1.5 */
+	0x1.fffffcp22f,      /* 2^23 - 1 */
+	0x1.fffffep22f,      /* 2^23 - 0.5 */
+	0x1.000000p23f,      /* 2^23 */
+	0x1.000002p23f,      /* 2^23 + 1 */
+	0x1.000004p23f,      /* 2^23 + 2 */
+	0x1.000006p23f,      /* 2^23 + 3 */
+	0x1.000008p23f,      /* 2^23 + 4 */
+
+	0x1.fffff0p23f,      /* 2^24 - 8 */
+	0x1.fffff2p23f,      /* 2^24 - 7 */
+	0x1.fffff4p23f,      /* 2^24 - 6 */
+	0x1.fffff6p23f,      /* 2^24 - 5 */
+	0x1.fffff8p23f,      /* 2^24 - 4 */
+	0x1.fffffap23f,      /* 2^24 - 3 */
+	0x1.fffffcp23f,      /* 2^24 - 2 */
+	0x1.fffffep23f,      /* 2^24 - 1 */
+	0x1.000000p24f,      /* 2^24 */
+	0x1.000002p24f,      /* 2^24 + 2 */
+	0x1.000004p24f,      /* 2^24 + 4 */
+	0x1.000006p24f,      /* 2^24 + 6 */
+	0x1.000008p24f,      /* 2^24 + 8 */
+
+	0x1.fffffep100f,     /* large integer */
+
+	/* Same as above but negative */
+
+	-0x0.000000p0f,       /* zero */
+	-0x0.000002p-126f,    /* smallest denormal > 0 */
+	-0x1.000000p-126f,    /* smallest normal > 0 */
+	-0x1.fffffep-2f,      /* largest < 0.5 */
+	-0x1.000000p-1f,      /* 0.5 */
+	-0x1.000002p-1f,      /* smallest > 0.5 */
+	-0x1.fffffep-1f,      /* largest < 1 */
+	-0x1.000000p0f,       /* 1 */
+	-0x1.000002p0f,       /* smallest > 1 */
+	-0x1.7ffffep0f,       /* largest < 1.5 */
+	-0x1.800000p0f,       /* 1.5 */
+	-0x1.800002p0f,       /* smallest > 1.5 */
+	-0x1.fffffep0f,       /* largest < 2 */
+	-0x1.000000p1f,       /* 2 */
+	-0x1.000002p1f,       /* smallest > 2 */
+	-0x1.3ffffep1f,       /* largest < 2.5 */
+	-0x1.400000p1f,       /* 2.5 */
+	-0x1.400002p1f,       /* smallest > 2.5 */
+	-0x1.7ffffep1f,       /* largest < 3 */
+	-0x1.800000p1f,       /* 3 */
+	-0x1.800002p1f,       /* smallest > 3 */
+	-0x1.bffffep1f,       /* largest < 3.5 */
+	-0x1.c00000p1f,       /* 3.5 */
+	-0x1.c00002p1f,       /* smallest > 3.5 */
+	-0x1.fffffep1f,       /* largest < 4 */
+	-0x1.000000p2f,       /* 4 */
+	-0x1.000002p2f,       /* smallest > 4 */
+
+	-0x1.ffffe0p20f,      /* 2^21 - 2 */
+	-0x1.ffffe2p20f,      /* 2^21 - 1.875 */
+	-0x1.ffffe4p20f,      /* 2^21 - 1.75 */
+	-0x1.ffffe6p20f,      /* 2^21 - 1.625 */
+	-0x1.ffffe8p20f,      /* 2^21 - 1.5 */
+	-0x1.ffffeap20f,      /* 2^21 - 1.375 */
+	-0x1.ffffecp20f,      /* 2^21 - 1.25 */
+	-0x1.ffffeep20f,      /* 2^21 - 1.125 */
+	-0x1.fffff0p20f,      /* 2^21 - 1 */
+	-0x1.fffff2p20f,      /* 2^21 - 0.875 */
+	-0x1.fffff4p20f,      /* 2^21 - 0.75 */
+	-0x1.fffff6p20f,      /* 2^21 - 0.625 */
+	-0x1.fffff8p20f,      /* 2^21 - 0.5 */
+	-0x1.fffffap20f,      /* 2^21 - 0.375 */
+	-0x1.fffffcp20f,      /* 2^21 - 0.25 */
+	-0x1.fffffep20f,      /* 2^21 - 0.125 */
+	-0x1.000000p21f,      /* 2^21 */
+	-0x1.000002p21f,      /* 2^21 + 0.25 */
+	-0x1.000004p21f,      /* 2^21 + 0.5 */
+	-0x1.000006p21f,      /* 2^21 + 0.75 */
+	-0x1.000008p21f,      /* 2^21 + 1 */
+	-0x1.00000ap21f,      /* 2^21 + 1.25 */
+	-0x1.00000cp21f,      /* 2^21 + 1.5 */
+	-0x1.00000ep21f,      /* 2^21 + 1.75 */
+	-0x1.000010p21f,      /* 2^21 + 2 */
+
+	-0x1.fffff0p21f,      /* 2^22 - 2 */
+	-0x1.fffff2p21f,      /* 2^22 - 1.75 */
+	-0x1.fffff4p21f,      /* 2^22 - 1.5 */
+	-0x1.fffff6p21f,      /* 2^22 - 1.25 */
+	-0x1.fffff8p21f,      /* 2^22 - 1 */
+	-0x1.fffffap21f,      /* 2^22 - 0.75 */
+	-0x1.fffffcp21f,      /* 2^22 - 0.5 */
+	-0x1.fffffep21f,      /* 2^22 - 0.25 */
+	-0x1.000000p22f,      /* 2^22 */
+	-0x1.000002p22f,      /* 2^22 + 0.5 */
+	-0x1.000004p22f,      /* 2^22 + 1 */
+	-0x1.000006p22f,      /* 2^22 + 1.5 */
+	-0x1.000008p22f,      /* 2^22 + 2 */
+
+	-0x1.fffff0p22f,      /* 2^23 - 4 */
+	-0x1.fffff2p22f,      /* 2^23 - 3.5 */
+	-0x1.fffff4p22f,      /* 2^23 - 3 */
+	-0x1.fffff6p22f,      /* 2^23 - 2.5 */
+	-0x1.fffff8p22f,      /* 2^23 - 2 */
+	-0x1.fffffap22f,      /* 2^23 - 1.5 */
+	-0x1.fffffcp22f,      /* 2^23 - 1 */
+	-0x1.fffffep22f,      /* 2^23 - 0.5 */
+	-0x1.000000p23f,      /* 2^23 */
+	-0x1.000002p23f,      /* 2^23 + 1 */
+	-0x1.000004p23f,      /* 2^23 + 2 */
+	-0x1.000006p23f,      /* 2^23 + 3 */
+	-0x1.000008p23f,      /* 2^23 + 4 */
+
+	-0x1.fffff0p23f,      /* 2^24 - 8 */
+	-0x1.fffff2p23f,      /* 2^24 - 7 */
+	-0x1.fffff4p23f,      /* 2^24 - 6 */
+	-0x1.fffff6p23f,      /* 2^24 - 5 */
+	-0x1.fffff8p23f,      /* 2^24 - 4 */
+	-0x1.fffffap23f,      /* 2^24 - 3 */
+	-0x1.fffffcp23f,      /* 2^24 - 2 */
+	-0x1.fffffep23f,      /* 2^24 - 1 */
+	-0x1.000000p24f,      /* 2^24 */
+	-0x1.000002p24f,      /* 2^24 + 2 */
+	-0x1.000004p24f,      /* 2^24 + 4 */
+	-0x1.000006p24f,      /* 2^24 + 6 */
+	-0x1.000008p24f,      /* 2^24 + 8 */
+
+	-0x1.fffffep100f,     /* large integer with full mantissa */
+
+	/* a few random numbers*/
+	3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.499999, -600.0, 1.0
+};
+
+static float float_identity[FLOAT_CASES] = {
+	HUGE_VALF,
+	-HUGE_VALF,
+	__builtin_nanf(""),
+	-__builtin_nanf(""),
+	__builtin_nanf("0xdeadbe"),
+	-__builtin_nanf("0xdeadbe"),
+
+	0.0,
+	FLT_DENORM_MIN,    /* smallest denormal > 0 */
+	FLT_MIN,         /* smallest normal > 0 */
+	0.5 - (FLT_EPSILON / 4.),
+	0.5,
+	0.5 + (FLT_EPSILON / 2.),
+	1.0 - (FLT_EPSILON / 2.),
+	1.0,
+	1.0 + FLT_EPSILON,
+	1.5 - FLT_EPSILON,
+	1.5,
+	1.5 + FLT_EPSILON,
+	2.0 - FLT_EPSILON,
+	2.0,
+	2.0 + (2.0 * FLT_EPSILON),
+	2.5 - (2.0 * FLT_EPSILON),
+	2.5,
+	2.5 + (2.0 * FLT_EPSILON),
+	3.0 - (2.0 * FLT_EPSILON),
+	3.0,
+	3.0 + (2.0 * FLT_EPSILON),
+	3.5 - (2.0 * FLT_EPSILON),
+	3.5,
+	3.5 + (2.0 * FLT_EPSILON),
+	4.0 - (2.0 * FLT_EPSILON),
+	4.0,
+	4.0 + (4.0 * FLT_EPSILON),
+
+	2097150.000,     /* 2^21 - 2 */
+	2097150.125,     /* 2^21 - 1.875 */
+	2097150.250,     /* 2^21 - 1.75 */
+	2097150.375,     /* 2^21 - 1.625 */
+	2097150.500,     /* 2^21 - 1.5 */
+	2097150.625,     /* 2^21 - 1.375 */
+	2097150.750,     /* 2^21 - 1.25 */
+	2097150.875,     /* 2^21 - 1.125 */
+	2097151.000,     /* 2^21 - 1 */
+	2097151.125,     /* 2^21 - 0.875 */
+	2097151.250,     /* 2^21 - 0.75 */
+	2097151.375,     /* 2^21 - 0.625 */
+	2097151.500,     /* 2^21 - 0.5 */
+	2097151.625,     /* 2^21 - 0.375 */
+	2097151.750,     /* 2^21 - 0.25 */
+	2097151.875,     /* 2^21 - 0.125 */
+	2097152.00,      /* 2^21 */
+	2097152.25,      /* 2^21 + 0.25 */
+	2097152.50,      /* 2^21 + 0.5 */
+	2097152.75,      /* 2^21 + 0.75 */
+	2097153.00,      /* 2^21 + 1 */
+	2097153.25,      /* 2^21 + 1.25 */
+	2097153.50,      /* 2^21 + 1.5 */
+	2097153.75,      /* 2^21 + 1.75 */
+	2097154.00,      /* 2^21 + 2 */
+
+	4194302.00,      /* 2^22 - 2 */
+	4194302.25,      /* 2^22 - 1.75 */
+	4194302.50,      /* 2^22 - 1.5 */
+	4194302.75,      /* 2^22 - 1.25 */
+	4194303.00,      /* 2^22 - 1 */
+	4194303.25,      /* 2^22 - 0.75 */
+	4194303.50,      /* 2^22 - 0.5 */
+	4194303.75,      /* 2^22 - 0.25 */
+	4194304.0,       /* 2^22 */
+	4194304.5,       /* 2^22 + 0.5 */
+	4194305.0,       /* 2^22 + 1 */
+	4194305.5,       /* 2^22 + 1.5 */
+	4194306.0,       /* 2^22 + 2 */
+
+	8388604.0,      /* 2^23 - 4 */
+	8388604.5,      /* 2^23 - 3.5 */
+	8388605.0,      /* 2^23 - 3 */
+	8388605.5,      /* 2^23 - 2.5 */
+	8388606.0,      /* 2^23 - 2 */
+	8388606.5,      /* 2^23 - 1.5 */
+	8388607.0,      /* 2^23 - 1 */
+	8388607.5,      /* 2^23 - 0.5 */
+	8388608.0,      /* 2^23 */
+	8388609.0,      /* 2^23 + 1 */
+	8388610.0,      /* 2^23 + 2 */
+	8388611.0,      /* 2^23 + 3 */
+	8388612.0,      /* 2^23 + 4 */
+
+	16777208.0,      /* 2^24 - 8 */
+	16777209.0,      /* 2^24 - 7 */
+	16777210.0,      /* 2^24 - 6 */
+	16777211.0,      /* 2^24 - 5 */
+	16777212.0,      /* 2^24 - 4 */
+	16777213.0,      /* 2^24 - 3 */
+	16777214.0,      /* 2^24 - 2 */
+	16777215.0,      /* 2^24 - 1 */
+	16777216.0,      /* 2^24 */
+	16777218.0,      /* 2^24 + 2 */
+	16777220.0,      /* 2^24 + 4 */
+	16777222.0,      /* 2^24 + 6 */
+	16777224.0,      /* 2^24 + 8 */
+
+	0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* Same as above but negative */
+
+	-0.0,
+	-FLT_DENORM_MIN,    /* smallest denormal > 0 */
+	-FLT_MIN,         /* smallest normal > 0 */
+	-(0.5 - (FLT_EPSILON / 4.)),
+	-0.5,
+	-(0.5 + (FLT_EPSILON / 2.)),
+	-(1.0 - (FLT_EPSILON / 2.)),
+	-1.0,
+	-(1.0 + FLT_EPSILON),
+	-(1.5 - FLT_EPSILON),
+	-1.5,
+	-(1.5 + FLT_EPSILON),
+	-(2.0 - FLT_EPSILON),
+	-2.0,
+	-(2.0 + (2.0 * FLT_EPSILON)),
+	-(2.5 - (2.0 * FLT_EPSILON)),
+	-2.5,
+	-(2.5 + (2.0 * FLT_EPSILON)),
+	-(3.0 - (2.0 * FLT_EPSILON)),
+	-3.0,
+	-(3.0 + (2.0 * FLT_EPSILON)),
+	-(3.5 - (2.0 * FLT_EPSILON)),
+	-3.5,
+	-(3.5 + (2.0 * FLT_EPSILON)),
+	-(4.0 - (2.0 * FLT_EPSILON)),
+	-4.0,
+	-(4.0 + (4.0 * FLT_EPSILON)),
+
+	-2097150.000,     /* 2^21 - 2 */
+	-2097150.125,     /* 2^21 - 1.875 */
+	-2097150.250,     /* 2^21 - 1.75 */
+	-2097150.375,     /* 2^21 - 1.625 */
+	-2097150.500,     /* 2^21 - 1.5 */
+	-2097150.625,     /* 2^21 - 1.375 */
+	-2097150.750,     /* 2^21 - 1.25 */
+	-2097150.875,     /* 2^21 - 1.125 */
+	-2097151.000,     /* 2^21 - 1 */
+	-2097151.125,     /* 2^21 - 0.875 */
+	-2097151.250,     /* 2^21 - 0.75 */
+	-2097151.375,     /* 2^21 - 0.625 */
+	-2097151.500,     /* 2^21 - 0.5 */
+	-2097151.625,     /* 2^21 - 0.375 */
+	-2097151.750,     /* 2^21 - 0.25 */
+	-2097151.875,     /* 2^21 - 0.125 */
+	-2097152.00,      /* 2^21 */
+	-2097152.25,      /* 2^21 + 0.25 */
+	-2097152.50,      /* 2^21 + 0.5 */
+	-2097152.75,      /* 2^21 + 0.75 */
+	-2097153.00,      /* 2^21 + 1 */
+	-2097153.25,      /* 2^21 + 1.25 */
+	-2097153.50,      /* 2^21 + 1.5 */
+	-2097153.75,      /* 2^21 + 1.75 */
+	-2097154.00,      /* 2^21 + 2 */
+
+	-4194302.00,      /* 2^22 - 2 */
+	-4194302.25,      /* 2^22 - 1.75 */
+	-4194302.50,      /* 2^22 - 1.5 */
+	-4194302.75,      /* 2^22 - 1.25 */
+	-4194303.00,      /* 2^22 - 1 */
+	-4194303.25,      /* 2^22 - 0.75 */
+	-4194303.50,      /* 2^22 - 0.5 */
+	-4194303.75,      /* 2^22 - 0.25 */
+	-4194304.0,       /* 2^22 */
+	-4194304.5,       /* 2^22 + 0.5 */
+	-4194305.0,       /* 2^22 + 1 */
+	-4194305.5,       /* 2^22 + 1.5 */
+	-4194306.0,       /* 2^22 + 2 */
+
+	-8388604.0,      /* 2^23 - 4 */
+	-8388604.5,      /* 2^23 - 3.5 */
+	-8388605.0,      /* 2^23 - 3 */
+	-8388605.5,      /* 2^23 - 2.5 */
+	-8388606.0,      /* 2^23 - 2 */
+	-8388606.5,      /* 2^23 - 1.5 */
+	-8388607.0,      /* 2^23 - 1 */
+	-8388607.5,      /* 2^23 - 0.5 */
+	-8388608.0,      /* 2^23 */
+	-8388609.0,      /* 2^23 + 1 */
+	-8388610.0,      /* 2^23 + 2 */
+	-8388611.0,      /* 2^23 + 3 */
+	-8388612.0,      /* 2^23 + 4 */
+
+	-16777208.0,      /* 2^24 - 8 */
+	-16777209.0,      /* 2^24 - 7 */
+	-16777210.0,      /* 2^24 - 6 */
+	-16777211.0,      /* 2^24 - 5 */
+	-16777212.0,      /* 2^24 - 4 */
+	-16777213.0,      /* 2^24 - 3 */
+	-16777214.0,      /* 2^24 - 2 */
+	-16777215.0,      /* 2^24 - 1 */
+	-16777216.0,      /* 2^24 */
+	-16777218.0,      /* 2^24 + 2 */
+	-16777220.0,      /* 2^24 + 4 */
+	-16777222.0,      /* 2^24 + 6 */
+	-16777224.0,      /* 2^24 + 8 */
+
+	-0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* a few random numbers*/
+	3.5, -2.1, 100.0, 50.0, -1024.0, 0.0, 768.3156, 1080.5, -600.0, 1.0
+};
+
+static float float_results_trunc[FLOAT_CASES] = {
+	HUGE_VALF,
+	-HUGE_VALF,
+	__builtin_nanf(""),
+	-__builtin_nanf(""),
+	__builtin_nanf("0xdeadbe"),
+	-__builtin_nanf("0xdeadbe"),
+
+	0.0,
+	0.0,
+	0.0,
+	0.0,
+	0.0,
+	0.0,
+	0.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	4.0,
+	4.0,
+
+	2097150.000,     /* 2^21 - 2 */
+	2097150.000,     /* 2^21 - 1.875 */
+	2097150.000,     /* 2^21 - 1.75 */
+	2097150.000,     /* 2^21 - 1.625 */
+	2097150.000,     /* 2^21 - 1.5 */
+	2097150.000,     /* 2^21 - 1.375 */
+	2097150.000,     /* 2^21 - 1.25 */
+	2097150.000,     /* 2^21 - 1.125 */
+	2097151.000,     /* 2^21 - 1 */
+	2097151.000,     /* 2^21 - 0.875 */
+	2097151.000,     /* 2^21 - 0.75 */
+	2097151.000,     /* 2^21 - 0.625 */
+	2097151.000,     /* 2^21 - 0.5 */
+	2097151.000,     /* 2^21 - 0.375 */
+	2097151.000,     /* 2^21 - 0.25 */
+	2097151.000,     /* 2^21 - 0.125 */
+	2097152.00,      /* 2^21 */
+	2097152.00,      /* 2^21 + 0.25 */
+	2097152.00,      /* 2^21 + 0.5 */
+	2097152.00,      /* 2^21 + 0.75 */
+	2097153.00,      /* 2^21 + 1 */
+	2097153.00,      /* 2^21 + 1.25 */
+	2097153.00,      /* 2^21 + 1.5 */
+	2097153.00,      /* 2^21 + 1.75 */
+	2097154.00,      /* 2^21 + 2 */
+
+	4194302.00,      /* 2^22 - 2 */
+	4194302.00,      /* 2^22 - 1.75 */
+	4194302.00,      /* 2^22 - 1.5 */
+	4194302.00,      /* 2^22 - 1.25 */
+	4194303.00,      /* 2^22 - 1 */
+	4194303.00,      /* 2^22 - 0.75 */
+	4194303.00,      /* 2^22 - 0.5 */
+	4194303.00,      /* 2^22 - 0.25 */
+	4194304.0,       /* 2^22 */
+	4194304.0,       /* 2^22 + 0.5 */
+	4194305.0,       /* 2^22 + 1 */
+	4194305.0,       /* 2^22 + 1.5 */
+	4194306.0,       /* 2^22 + 2 */
+
+	8388604.0,      /* 2^23 - 4 */
+	8388604.0,      /* 2^23 - 3.5 */
+	8388605.0,      /* 2^23 - 3 */
+	8388605.0,      /* 2^23 - 2.5 */
+	8388606.0,      /* 2^23 - 2 */
+	8388606.0,      /* 2^23 - 1.5 */
+	8388607.0,      /* 2^23 - 1 */
+	8388607.0,      /* 2^23 - 0.5 */
+	8388608.0,      /* 2^23 */
+	8388609.0,      /* 2^23 + 1 */
+	8388610.0,      /* 2^23 + 2 */
+	8388611.0,      /* 2^23 + 3 */
+	8388612.0,      /* 2^23 + 4 */
+
+	16777208.0,      /* 2^24 - 8 */
+	16777209.0,      /* 2^24 - 7 */
+	16777210.0,      /* 2^24 - 6 */
+	16777211.0,      /* 2^24 - 5 */
+	16777212.0,      /* 2^24 - 4 */
+	16777213.0,      /* 2^24 - 3 */
+	16777214.0,      /* 2^24 - 2 */
+	16777215.0,      /* 2^24 - 1 */
+	16777216.0,      /* 2^24 */
+	16777218.0,      /* 2^24 + 2 */
+	16777220.0,      /* 2^24 + 4 */
+	16777222.0,      /* 2^24 + 6 */
+	16777224.0,      /* 2^24 + 8 */
+
+	0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* Same as above but negative */
+
+	-0.0,
+	-0.0,
+	-0.0,
+	-0.0,
+	-0.0,
+	-0.0,
+	-0.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-4.0,
+	-4.0,
+
+	-2097150.000,     /* 2^21 - 2 */
+	-2097150.000,     /* 2^21 - 1.875 */
+	-2097150.000,     /* 2^21 - 1.75 */
+	-2097150.000,     /* 2^21 - 1.625 */
+	-2097150.000,     /* 2^21 - 1.5 */
+	-2097150.000,     /* 2^21 - 1.375 */
+	-2097150.000,     /* 2^21 - 1.25 */
+	-2097150.000,     /* 2^21 - 1.125 */
+	-2097151.000,     /* 2^21 - 1 */
+	-2097151.000,     /* 2^21 - 0.875 */
+	-2097151.000,     /* 2^21 - 0.75 */
+	-2097151.000,     /* 2^21 - 0.625 */
+	-2097151.000,     /* 2^21 - 0.5 */
+	-2097151.000,     /* 2^21 - 0.375 */
+	-2097151.000,     /* 2^21 - 0.25 */
+	-2097151.000,     /* 2^21 - 0.125 */
+	-2097152.00,      /* 2^21 */
+	-2097152.00,      /* 2^21 + 0.25 */
+	-2097152.00,      /* 2^21 + 0.5 */
+	-2097152.00,      /* 2^21 + 0.75 */
+	-2097153.00,      /* 2^21 + 1 */
+	-2097153.00,      /* 2^21 + 1.25 */
+	-2097153.00,      /* 2^21 + 1.5 */
+	-2097153.00,      /* 2^21 + 1.75 */
+	-2097154.00,      /* 2^21 + 2 */
+
+	-4194302.00,      /* 2^22 - 2 */
+	-4194302.00,      /* 2^22 - 1.75 */
+	-4194302.00,      /* 2^22 - 1.5 */
+	-4194302.00,      /* 2^22 - 1.25 */
+	-4194303.00,      /* 2^22 - 1 */
+	-4194303.00,      /* 2^22 - 0.75 */
+	-4194303.00,      /* 2^22 - 0.5 */
+	-4194303.00,      /* 2^22 - 0.25 */
+	-4194304.0,       /* 2^22 */
+	-4194304.0,       /* 2^22 + 0.5 */
+	-4194305.0,       /* 2^22 + 1 */
+	-4194305.0,       /* 2^22 + 1.5 */
+	-4194306.0,       /* 2^22 + 2 */
+
+	-8388604.0,      /* 2^23 - 4 */
+	-8388604.0,      /* 2^23 - 3.5 */
+	-8388605.0,      /* 2^23 - 3 */
+	-8388605.0,      /* 2^23 - 2.5 */
+	-8388606.0,      /* 2^23 - 2 */
+	-8388606.0,      /* 2^23 - 1.5 */
+	-8388607.0,      /* 2^23 - 1 */
+	-8388607.0,      /* 2^23 - 0.5 */
+	-8388608.0,      /* 2^23 */
+	-8388609.0,      /* 2^23 + 1 */
+	-8388610.0,      /* 2^23 + 2 */
+	-8388611.0,      /* 2^23 + 3 */
+	-8388612.0,      /* 2^23 + 4 */
+
+	-16777208.0,      /* 2^24 - 8 */
+	-16777209.0,      /* 2^24 - 7 */
+	-16777210.0,      /* 2^24 - 6 */
+	-16777211.0,      /* 2^24 - 5 */
+	-16777212.0,      /* 2^24 - 4 */
+	-16777213.0,      /* 2^24 - 3 */
+	-16777214.0,      /* 2^24 - 2 */
+	-16777215.0,      /* 2^24 - 1 */
+	-16777216.0,      /* 2^24 */
+	-16777218.0,      /* 2^24 + 2 */
+	-16777220.0,      /* 2^24 + 4 */
+	-16777222.0,      /* 2^24 + 6 */
+	-16777224.0,      /* 2^24 + 8 */
+
+	-0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* a few random numbers*/
+	3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
+};
+
+static float float_results_round[FLOAT_CASES] = {
+	HUGE_VALF,
+	-HUGE_VALF,
+	__builtin_nanf(""),
+	-__builtin_nanf(""),
+	__builtin_nanf("0xdeadbe"),
+	-__builtin_nanf("0xdeadbe"),
+
+	0.0,
+	0.0,    /* smallest denormal > 0 */
+	0.0,         /* smallest normal > 0 */
+	0.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	4.0,
+	4.0,
+	4.0,
+	4.0,
+	4.0,
+
+	2097150.000,     /* 2^21 - 2 */
+	2097150.000,     /* 2^21 - 1.875 */
+	2097150.000,     /* 2^21 - 1.75 */
+	2097150.000,     /* 2^21 - 1.625 */
+	2097151.000,     /* 2^21 - 1.5 */
+	2097151.000,     /* 2^21 - 1.375 */
+	2097151.000,     /* 2^21 - 1.25 */
+	2097151.000,     /* 2^21 - 1.125 */
+	2097151.000,     /* 2^21 - 1 */
+	2097151.000,     /* 2^21 - 0.875 */
+	2097151.000,     /* 2^21 - 0.75 */
+	2097151.000,     /* 2^21 - 0.625 */
+	2097152.000,     /* 2^21 - 0.5 */
+	2097152.000,     /* 2^21 - 0.375 */
+	2097152.000,     /* 2^21 - 0.25 */
+	2097152.000,     /* 2^21 - 0.125 */
+	2097152.00,      /* 2^21 */
+	2097152.00,      /* 2^21 + 0.25 */
+	2097153.00,      /* 2^21 + 0.5 */
+	2097153.00,      /* 2^21 + 0.75 */
+	2097153.00,      /* 2^21 + 1 */
+	2097153.00,      /* 2^21 + 1.25 */
+	2097154.00,      /* 2^21 + 1.5 */
+	2097154.00,      /* 2^21 + 1.75 */
+	2097154.00,      /* 2^21 + 2 */
+
+	4194302.00,      /* 2^22 - 2 */
+	4194302.00,      /* 2^22 - 1.75 */
+	4194303.00,      /* 2^22 - 1.5 */
+	4194303.00,      /* 2^22 - 1.25 */
+	4194303.00,      /* 2^22 - 1 */
+	4194303.00,      /* 2^22 - 0.75 */
+	4194304.00,      /* 2^22 - 0.5 */
+	4194304.00,      /* 2^22 - 0.25 */
+	4194304.0,       /* 2^22 */
+	4194305.0,       /* 2^22 + 0.5 */
+	4194305.0,       /* 2^22 + 1 */
+	4194306.0,       /* 2^22 + 1.5 */
+	4194306.0,       /* 2^22 + 2 */
+
+	8388604.0,      /* 2^23 - 4 */
+	8388605.0,      /* 2^23 - 3.5 */
+	8388605.0,      /* 2^23 - 3 */
+	8388606.0,      /* 2^23 - 2.5 */
+	8388606.0,      /* 2^23 - 2 */
+	8388607.0,      /* 2^23 - 1.5 */
+	8388607.0,      /* 2^23 - 1 */
+	8388608.0,      /* 2^23 - 0.5 */
+	8388608.0,      /* 2^23 */
+	8388609.0,      /* 2^23 + 1 */
+	8388610.0,      /* 2^23 + 2 */
+	8388611.0,      /* 2^23 + 3 */
+	8388612.0,      /* 2^23 + 4 */
+
+	16777208.0,      /* 2^24 - 8 */
+	16777209.0,      /* 2^24 - 7 */
+	16777210.0,      /* 2^24 - 6 */
+	16777211.0,      /* 2^24 - 5 */
+	16777212.0,      /* 2^24 - 4 */
+	16777213.0,      /* 2^24 - 3 */
+	16777214.0,      /* 2^24 - 2 */
+	16777215.0,      /* 2^24 - 1 */
+	16777216.0,      /* 2^24 */
+	16777218.0,      /* 2^24 + 2 */
+	16777220.0,      /* 2^24 + 4 */
+	16777222.0,      /* 2^24 + 6 */
+	16777224.0,      /* 2^24 + 8 */
+
+	0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* Same as above but negative */
+
+	-0.0,
+	-0.0,    /* smallest denormal > 0 */
+	-0.0,         /* smallest normal > 0 */
+	-0.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-4.0,
+	-4.0,
+	-4.0,
+	-4.0,
+	-4.0,
+
+	-2097150.000,     /* 2^21 - 2 */
+	-2097150.000,     /* 2^21 - 1.875 */
+	-2097150.000,     /* 2^21 - 1.75 */
+	-2097150.000,     /* 2^21 - 1.625 */
+	-2097151.000,     /* 2^21 - 1.5 */
+	-2097151.000,     /* 2^21 - 1.375 */
+	-2097151.000,     /* 2^21 - 1.25 */
+	-2097151.000,     /* 2^21 - 1.125 */
+	-2097151.000,     /* 2^21 - 1 */
+	-2097151.000,     /* 2^21 - 0.875 */
+	-2097151.000,     /* 2^21 - 0.75 */
+	-2097151.000,     /* 2^21 - 0.625 */
+	-2097152.000,     /* 2^21 - 0.5 */
+	-2097152.000,     /* 2^21 - 0.375 */
+	-2097152.000,     /* 2^21 - 0.25 */
+	-2097152.000,     /* 2^21 - 0.125 */
+	-2097152.00,      /* 2^21 */
+	-2097152.00,      /* 2^21 + 0.25 */
+	-2097153.00,      /* 2^21 + 0.5 */
+	-2097153.00,      /* 2^21 + 0.75 */
+	-2097153.00,      /* 2^21 + 1 */
+	-2097153.00,      /* 2^21 + 1.25 */
+	-2097154.00,      /* 2^21 + 1.5 */
+	-2097154.00,      /* 2^21 + 1.75 */
+	-2097154.00,      /* 2^21 + 2 */
+
+	-4194302.00,      /* 2^22 - 2 */
+	-4194302.00,      /* 2^22 - 1.75 */
+	-4194303.00,      /* 2^22 - 1.5 */
+	-4194303.00,      /* 2^22 - 1.25 */
+	-4194303.00,      /* 2^22 - 1 */
+	-4194303.00,      /* 2^22 - 0.75 */
+	-4194304.00,      /* 2^22 - 0.5 */
+	-4194304.00,      /* 2^22 - 0.25 */
+	-4194304.0,       /* 2^22 */
+	-4194305.0,       /* 2^22 + 0.5 */
+	-4194305.0,       /* 2^22 + 1 */
+	-4194306.0,       /* 2^22 + 1.5 */
+	-4194306.0,       /* 2^22 + 2 */
+
+	-8388604.0,      /* 2^23 - 4 */
+	-8388605.0,      /* 2^23 - 3.5 */
+	-8388605.0,      /* 2^23 - 3 */
+	-8388606.0,      /* 2^23 - 2.5 */
+	-8388606.0,      /* 2^23 - 2 */
+	-8388607.0,      /* 2^23 - 1.5 */
+	-8388607.0,      /* 2^23 - 1 */
+	-8388608.0,      /* 2^23 - 0.5 */
+	-8388608.0,      /* 2^23 */
+	-8388609.0,      /* 2^23 + 1 */
+	-8388610.0,      /* 2^23 + 2 */
+	-8388611.0,      /* 2^23 + 3 */
+	-8388612.0,      /* 2^23 + 4 */
+
+	-16777208.0,      /* 2^24 - 8 */
+	-16777209.0,      /* 2^24 - 7 */
+	-16777210.0,      /* 2^24 - 6 */
+	-16777211.0,      /* 2^24 - 5 */
+	-16777212.0,      /* 2^24 - 4 */
+	-16777213.0,      /* 2^24 - 3 */
+	-16777214.0,      /* 2^24 - 2 */
+	-16777215.0,      /* 2^24 - 1 */
+	-16777216.0,      /* 2^24 */
+	-16777218.0,      /* 2^24 + 2 */
+	-16777220.0,      /* 2^24 + 4 */
+	-16777222.0,      /* 2^24 + 6 */
+	-16777224.0,      /* 2^24 + 8 */
+
+	-0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* a few random numbers*/
+	4.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1081.0, -600.0, 1.0
+};
+
+static float float_results_nearbyint[FLOAT_CASES] = {
+	HUGE_VALF,
+	-HUGE_VALF,
+	__builtin_nanf(""),
+	-__builtin_nanf(""),
+	__builtin_nanf("0xdeadbe"),
+	-__builtin_nanf("0xdeadbe"),
+
+	0.0,
+	0.0,    /* smallest denormal > 0 */
+	0.0,         /* smallest normal > 0 */
+	0.0,
+	0.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	1.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	2.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	3.0,
+	4.0,
+	4.0,
+	4.0,
+	4.0,
+	4.0,
+
+	2097150.000,     /* 2^21 - 2 */
+	2097150.000,     /* 2^21 - 1.875 */
+	2097150.000,     /* 2^21 - 1.75 */
+	2097150.000,     /* 2^21 - 1.625 */
+	2097150.000,     /* 2^21 - 1.5 */
+	2097151.000,     /* 2^21 - 1.375 */
+	2097151.000,     /* 2^21 - 1.25 */
+	2097151.000,     /* 2^21 - 1.125 */
+	2097151.000,     /* 2^21 - 1 */
+	2097151.000,     /* 2^21 - 0.875 */
+	2097151.000,     /* 2^21 - 0.75 */
+	2097151.000,     /* 2^21 - 0.625 */
+	2097152.000,     /* 2^21 - 0.5 */
+	2097152.000,     /* 2^21 - 0.375 */
+	2097152.000,     /* 2^21 - 0.25 */
+	2097152.000,     /* 2^21 - 0.125 */
+	2097152.00,      /* 2^21 */
+	2097152.00,      /* 2^21 + 0.25 */
+	2097152.00,      /* 2^21 + 0.5 */
+	2097153.00,      /* 2^21 + 0.75 */
+	2097153.00,      /* 2^21 + 1 */
+	2097153.00,      /* 2^21 + 1.25 */
+	2097154.00,      /* 2^21 + 1.5 */
+	2097154.00,      /* 2^21 + 1.75 */
+	2097154.00,      /* 2^21 + 2 */
+
+	4194302.00,      /* 2^22 - 2 */
+	4194302.00,      /* 2^22 - 1.75 */
+	4194302.00,      /* 2^22 - 1.5 */
+	4194303.00,      /* 2^22 - 1.25 */
+	4194303.00,      /* 2^22 - 1 */
+	4194303.00,      /* 2^22 - 0.75 */
+	4194304.00,      /* 2^22 - 0.5 */
+	4194304.0,      /* 2^22 - 0.25 */
+	4194304.0,       /* 2^22 */
+	4194304.0,       /* 2^22 + 0.5 */
+	4194305.0,       /* 2^22 + 1 */
+	4194306.0,       /* 2^22 + 1.5 */
+	4194306.0,       /* 2^22 + 2 */
+
+	8388604.0,      /* 2^23 - 4 */
+	8388604.0,      /* 2^23 - 3.5 */
+	8388605.0,      /* 2^23 - 3 */
+	8388606.0,      /* 2^23 - 2.5 */
+	8388606.0,      /* 2^23 - 2 */
+	8388606.0,      /* 2^23 - 1.5 */
+	8388607.0,      /* 2^23 - 1 */
+	8388608.0,      /* 2^23 - 0.5 */
+	8388608.0,      /* 2^23 */
+	8388609.0,      /* 2^23 + 1 */
+	8388610.0,      /* 2^23 + 2 */
+	8388611.0,      /* 2^23 + 3 */
+	8388612.0,      /* 2^23 + 4 */
+
+	16777208.0,      /* 2^24 - 8 */
+	16777209.0,      /* 2^24 - 7 */
+	16777210.0,      /* 2^24 - 6 */
+	16777211.0,      /* 2^24 - 5 */
+	16777212.0,      /* 2^24 - 4 */
+	16777213.0,      /* 2^24 - 3 */
+	16777214.0,      /* 2^24 - 2 */
+	16777215.0,      /* 2^24 - 1 */
+	16777216.0,      /* 2^24 */
+	16777218.0,      /* 2^24 + 2 */
+	16777220.0,      /* 2^24 + 4 */
+	16777222.0,      /* 2^24 + 6 */
+	16777224.0,      /* 2^24 + 8 */
+
+	0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* Same as above but negative */
+
+	-0.0,
+	-0.0,    /* smallest denormal > 0 */
+	-0.0,         /* smallest normal > 0 */
+	-0.0,
+	-0.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-1.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-2.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-3.0,
+	-4.0,
+	-4.0,
+	-4.0,
+	-4.0,
+	-4.0,
+
+	-2097150.000,     /* 2^21 - 2 */
+	-2097150.000,     /* 2^21 - 1.875 */
+	-2097150.000,     /* 2^21 - 1.75 */
+	-2097150.000,     /* 2^21 - 1.625 */
+	-2097150.000,     /* 2^21 - 1.5 */
+	-2097151.000,     /* 2^21 - 1.375 */
+	-2097151.000,     /* 2^21 - 1.25 */
+	-2097151.000,     /* 2^21 - 1.125 */
+	-2097151.000,     /* 2^21 - 1 */
+	-2097151.000,     /* 2^21 - 0.875 */
+	-2097151.000,     /* 2^21 - 0.75 */
+	-2097151.000,     /* 2^21 - 0.625 */
+	-2097152.000,     /* 2^21 - 0.5 */
+	-2097152.000,     /* 2^21 - 0.375 */
+	-2097152.000,     /* 2^21 - 0.25 */
+	-2097152.000,     /* 2^21 - 0.125 */
+	-2097152.00,      /* 2^21 */
+	-2097152.00,      /* 2^21 + 0.25 */
+	-2097152.00,      /* 2^21 + 0.5 */
+	-2097153.00,      /* 2^21 + 0.75 */
+	-2097153.00,      /* 2^21 + 1 */
+	-2097153.00,      /* 2^21 + 1.25 */
+	-2097154.00,      /* 2^21 + 1.5 */
+	-2097154.00,      /* 2^21 + 1.75 */
+	-2097154.00,      /* 2^21 + 2 */
+
+	-4194302.00,      /* 2^22 - 2 */
+	-4194302.00,      /* 2^22 - 1.75 */
+	-4194302.00,      /* 2^22 - 1.5 */
+	-4194303.00,      /* 2^22 - 1.25 */
+	-4194303.00,      /* 2^22 - 1 */
+	-4194303.00,      /* 2^22 - 0.75 */
+	-4194304.00,      /* 2^22 - 0.5 */
+	-4194304.0,      /* 2^22 - 0.25 */
+	-4194304.0,       /* 2^22 */
+	-4194304.0,       /* 2^22 + 0.5 */
+	-4194305.0,       /* 2^22 + 1 */
+	-4194306.0,       /* 2^22 + 1.5 */
+	-4194306.0,       /* 2^22 + 2 */
+
+	-8388604.0,      /* 2^23 - 4 */
+	-8388604.0,      /* 2^23 - 3.5 */
+	-8388605.0,      /* 2^23 - 3 */
+	-8388606.0,      /* 2^23 - 2.5 */
+	-8388606.0,      /* 2^23 - 2 */
+	-8388606.0,      /* 2^23 - 1.5 */
+	-8388607.0,      /* 2^23 - 1 */
+	-8388608.0,      /* 2^23 - 0.5 */
+	-8388608.0,      /* 2^23 */
+	-8388609.0,      /* 2^23 + 1 */
+	-8388610.0,      /* 2^23 + 2 */
+	-8388611.0,      /* 2^23 + 3 */
+	-8388612.0,      /* 2^23 + 4 */
+
+	-16777208.0,      /* 2^24 - 8 */
+	-16777209.0,      /* 2^24 - 7 */
+	-16777210.0,      /* 2^24 - 6 */
+	-16777211.0,      /* 2^24 - 5 */
+	-16777212.0,      /* 2^24 - 4 */
+	-16777213.0,      /* 2^24 - 3 */
+	-16777214.0,      /* 2^24 - 2 */
+	-16777215.0,      /* 2^24 - 1 */
+	-16777216.0,      /* 2^24 */
+	-16777218.0,      /* 2^24 + 2 */
+	-16777220.0,      /* 2^24 + 4 */
+	-16777222.0,      /* 2^24 + 6 */
+	-16777224.0,      /* 2^24 + 8 */
+
+	-0x1.fffffep100f,   /* large integer with full mantissa */
+
+	/* a few random numbers*/
+	4.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
+};
+
+#if 0
+static double double_arguments[DOUBLE_CASES] = {
+	0.0000000000000p0
+};
+
+static double double_results_trunc[DOUBLE_CASES] = {
+};
+#endif
+
+PCUT_TEST(identity)
+{
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint32_t f1 = fint(float_arguments[i]);
+		uint32_t f2 = fint(float_identity[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%08x != 0x%08x\n", i, f1, f2);
+		}
+	}
+}
+
+PCUT_TEST(truncf)
+{
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint32_t f1 = fint(truncf(float_arguments[i]));
+		uint32_t f2 = fint(float_results_trunc[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%08x != 0x%08x\n", i, f1, f2);
+		}
+	}
+}
+
+PCUT_TEST(trunc)
+{
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint64_t f1 = dint(trunc(float_arguments[i]));
+		uint64_t f2 = dint(float_results_trunc[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%016"PRIx64" != 0x%016"PRIx64"\n", i, f1, f2);
+		}
+	}
+
+	// TODO: double test cases
+}
+
+PCUT_TEST(roundf)
+{
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint32_t f1 = fint(roundf(float_arguments[i]));
+		uint32_t f2 = fint(float_results_round[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%08x != 0x%08x\n", i, f1, f2);
+		}
+	}
+}
+
+PCUT_TEST(round)
+{
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint64_t f1 = dint(round(float_arguments[i]));
+		uint64_t f2 = dint(float_results_round[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%016"PRIx64" != 0x%016"PRIx64"\n", i, f1, f2);
+		}
+	}
+
+	// TODO: double test cases
+}
+
+PCUT_TEST(nearbyintf)
+{
+	// FIXME: ensure default rounding mode
+
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint32_t f1 = fint(nearbyintf(float_arguments[i]));
+		uint32_t f2 = fint(float_results_nearbyint[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%08x != 0x%08x\n", i, f1, f2);
+		}
+	}
+}
+
+PCUT_TEST(nearbyint)
+{
+	// FIXME: ensure default rounding mode
+
+	for (int i = 0; i < FLOAT_CASES; i++) {
+		uint64_t f1 = dint(nearbyint(float_arguments[i]));
+		uint64_t f2 = dint(float_results_nearbyint[i]);
+		if (f1 != f2) {
+			PCUT_ASSERTION_FAILED("case %d: 0x%016"PRIx64" != 0x%016"PRIx64"\n", i, f1, f2);
+		}
+	}
+
+	// TODO: double test cases
+}
+
+PCUT_EXPORT(rounding);
+
