X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=tests%2Ftest-truncf-ieee.c;h=9d808a240aa4ab492c944d15002707281704d7b7;hb=74a0def25839a0c6934ca611e605694840877140;hp=c5c779ae7054fb321e6988c0fe0d828a77fa83b9;hpb=fdb0fd9e820d721e6492b041ddc49d49b4c61e64;p=gnulib.git diff --git a/tests/test-truncf-ieee.c b/tests/test-truncf-ieee.c index c5c779ae7..9d808a240 100644 --- a/tests/test-truncf-ieee.c +++ b/tests/test-truncf-ieee.c @@ -1,5 +1,5 @@ /* Test of rounding towards zero. - Copyright (C) 2010 Free Software Foundation, Inc. + Copyright (C) 2010-2012 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -24,9 +24,20 @@ int main () { + /* See IEEE 754, section 6.3: + "the sign of the result of the round floating-point number to + integral value operation is the sign of the operand. These rules + shall apply even when operands or results are zero or infinite." */ + /* Zero. */ ASSERT (!signbit (truncf (0.0f))); ASSERT (!!signbit (truncf (minus_zerof)) == !!signbit (minus_zerof)); + /* Positive numbers. */ + ASSERT (!signbit (truncf (0.3f))); + ASSERT (!signbit (truncf (0.7f))); + /* Negative numbers. */ + ASSERT (!!signbit (truncf (-0.3f)) == !!signbit (minus_zerof)); + ASSERT (!!signbit (truncf (-0.7f)) == !!signbit (minus_zerof)); return 0; }