From aa567bf133b70db92f9f01aa5ce0ce7958542182 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Mon, 28 Aug 2017 11:17:22 +0200 Subject: [PATCH] [liba] Add comment regarding nearbyintf Change-Id: I6c02f2fe19cccce60516ad36062bc736e803991a --- liba/src/nearbyintf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/liba/src/nearbyintf.c b/liba/src/nearbyintf.c index 9d214291b..ca0e261e6 100644 --- a/liba/src/nearbyintf.c +++ b/liba/src/nearbyintf.c @@ -1,5 +1,17 @@ #include +/* nearbyintf is not supposed to be the same as roundf according to openBSD + * documentation. Indeed: + * - they round halfway cases to the nearest integer instead of away from zero + * (nearbyint(4.5) = 4 while round(4.5) = 5 for example). + * - nearbyint is guaranteed never to set floating point flags or trigger + * floating point exceptions (which are disabled by default) + * accroding to openBSD open manual page. + * + * However, as nearbyintf is required by micropython only, in order to save + * space and time (nearbyintf openBSD 6.0 implementation required some other + * function implementation), we used roundf. */ + float nearbyintf(float x) { return roundf(x); }