summaryrefslogtreecommitdiff
path: root/AK/Types.h
diff options
context:
space:
mode:
authorDan Klishch <danilklishch@gmail.com>2022-11-04 11:19:27 -0400
committerAndrew Kaster <andrewdkaster@gmail.com>2022-11-05 16:04:12 -0600
commit73f4cfa93056556ec454e87147f38dd4a17b0e93 (patch)
treea65deae925fb8115457e98906597db449350d4f9 /AK/Types.h
parent266882937d8879c92bf3b386a3cd1d23c5d235bb (diff)
downloadserenity-73f4cfa93056556ec454e87147f38dd4a17b0e93.zip
AK: Introduce fixed-width floating point types (f32, f64, f80 and f128)
Diffstat (limited to 'AK/Types.h')
-rw-r--r--AK/Types.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/AK/Types.h b/AK/Types.h
index 7b16d75362..6646fd4254 100644
--- a/AK/Types.h
+++ b/AK/Types.h
@@ -19,6 +19,22 @@ using i32 = __INT32_TYPE__;
using i16 = __INT16_TYPE__;
using i8 = __INT8_TYPE__;
+#ifndef KERNEL
+using f32 = float;
+static_assert(__FLT_MANT_DIG__ == 24 && __FLT_MAX_EXP__ == 128);
+
+using f64 = double;
+static_assert(__DBL_MANT_DIG__ == 53 && __DBL_MAX_EXP__ == 1024);
+
+# if __LDBL_MANT_DIG__ == 64 && __LDBL_MAX_EXP__ == 16384
+# define AK_HAS_FLOAT_80 1
+using f80 = long double;
+# elif __LDBL_MANT_DIG__ == 113 && __LDBL_MAX_EXP__ == 16384
+# define AK_HAS_FLOAT_128 1
+using f128 = long double;
+# endif
+#endif
+
#ifdef AK_OS_SERENITY
using size_t = __SIZE_TYPE__;