Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/libm/noieee_src Provide all missing variants of trunc/fl...
details: https://anonhg.NetBSD.org/src/rev/8120ef4162fa
branches: trunk
changeset: 327757:8120ef4162fa
user: martin <martin%NetBSD.org@localhost>
date: Sun Mar 16 09:51:39 2014 +0000
description:
Provide all missing variants of trunc/floor/ceil.
diffstat:
lib/libm/noieee_src/n_floor.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diffs (38 lines):
diff -r 0ca3c9dbdaf1 -r 8120ef4162fa lib/libm/noieee_src/n_floor.c
--- a/lib/libm/noieee_src/n_floor.c Sun Mar 16 09:37:47 2014 +0000
+++ b/lib/libm/noieee_src/n_floor.c Sun Mar 16 09:51:39 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: n_floor.c,v 1.7 2010/12/09 22:52:59 abs Exp $ */
+/* $NetBSD: n_floor.c,v 1.8 2014/03/16 09:51:39 martin Exp $ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -45,6 +45,12 @@
#define L vccast(L)
#endif
+#ifdef __weak_alias
+__weak_alias(ceill, ceil);
+__weak_alias(floorl, floor);
+__weak_alias(truncl, trunc);
+#endif
+
/*
* floor(x) := the largest integer no larger than x;
* ceil(x) := -floor(-x), for all real x.
@@ -216,3 +222,15 @@
t = x + s; /* x+s rounded to integer */
return (t - s);
}
+
+double
+trunc(double x)
+{
+ return x < 0 ? ceil(x) : floor(x);
+}
+
+float
+truncf(float x)
+{
+ return x < 0 ? ceilf(x) : floorf(x);
+}
Home |
Main Index |
Thread Index |
Old Index