packages feed

ieee754 0.7.6 → 0.7.8

raw patch · 4 files changed

+90/−26 lines, 4 files

Files

NEWS view
@@ -1,3 +1,16 @@+Changes in 0.7.8:++* Alain O'Dea fixed broken illumos build.++* Simplified endianness detection in C code.+++Changes in 0.7.7:++* Johan Kiviniemi added tests for minNormal, maxFinite, epsilon,+  maxNaNPayload.++ Changes in 0.7.6:  * Fix broken windows build.
cbits/feqrel_source.c view
@@ -1,34 +1,41 @@ /* adapted from Tango version 0.99.9, BSD Licensed  */ -/* Endianness detection modified from http://esr.ibiblio.org/?p=5095 and++/* Define WORDS_BIGENDIAN on big-endian platforms; otherwise, assume+ * little-endian.+ *+ * Endianness detection modified from http://esr.ibiblio.org/?p=5095 and  * https://gist.github.com/panzi/6856583 .  *- * We are assuming that the endianness is the same for integers and floats;- * this is true for modern systems but false in a few historical machines and- * some old ARM processors; see+ * In the subsequent code we rely on endianness being the same for integers+ * and floats; this is true for modern systems but false in a few historical+ * machines and some old ARM processors; see  * http://en.wikipedia.org/wiki/Endianness#Floating-point_and_endianness .  */--/*-   __BIG_ENDIAN__ and __LITTLE_ENDIAN__ are defined in some gcc versions-  only, probably depending on the architecture. Try to use endian.h if-  the gcc way fails - endian.h also does not seem to be available on all-  platforms.-*/--/* Assume Windows is little endian (http://stackoverflow.com/a/6449581 ) */-#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__LITTLE_ENDIAN__)-#  define __LITTLE_ENDIAN__-#endif--#ifdef __BIG_ENDIAN__+#if defined(__BYTE_ORDER__)+/* (1) Try to use the GCC/Clang __BYTE_ORDER__ defines */+#  if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__+#    define WORDS_BIGENDIAN 1+#  elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__+#    undef WORDS_BIGENDIAN+#  else+#    error byte order not supported+#  endif+/* (2) Otherwise, try the __BIG_ENDIAN__ and __LITTLE_ENDIAN__ defines */+#elif defined(__BIG_ENDIAN__) #  define WORDS_BIGENDIAN 1+#elif defined(__LITTLE_ENDIAN__)+#  undef WORDS_BIGENDIAN #else-#  ifdef __LITTLE_ENDIAN__+/* (3) As a last resort, try platform-specific fallbacks: */+#  if defined(_WIN16) || defined(_WIN32) || defined(_WIN64)+/*   (a) Assume Windows is little endian (http://stackoverflow.com/a/6449581 ) */ #    undef WORDS_BIGENDIAN #  else-#    if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)+/*   (b) Otherwise, use endian.h */+#    if (defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) \+         || defined(__OpenBSD__)) #      include <sys/endian.h> #    else #      include <endian.h>@@ -38,10 +45,10 @@ #    elif __BYTE_ORDER == __LITTLE_ENDIAN #      undef WORDS_BIGENDIAN #    else-#      error "unable to determine endianess!"-#    endif /* __BYTE_ORDER */-#  endif /* __LITTLE_ENDIAN__ */-#endif /* __BIG_ENDIAN__ */+#      error platform not supported: unable to determine endianess+#    endif+#  endif+#endif   /* REAL_EXPMASK is a ushort mask to select the exponent portion (without sign)
ieee754.cabal view
@@ -1,5 +1,5 @@ name:            ieee754-version:         0.7.6+version:         0.7.8 homepage:        http://github.com/patperry/hs-ieee754 synopsis:        Utilities for dealing with IEEE floating point numbers description:@@ -9,7 +9,7 @@ category:        Math license:         BSD3 license-file:    LICENSE-copyright:       (c) 2011. Patrick Perry <patperry@gmail.com>+copyright:       (c) 2011-2016. Patrick Perry <patperry@gmail.com> author:          Patrick Perry maintainer:      Patrick Perry <patperry@gmail.com> cabal-version: >= 1.2.0
tests/Tests.hs view
@@ -168,6 +168,36 @@ test_infinity_F1 = isInfinite (infinity :: F) @?= True test_infinity_F2 = infinity > (0 :: F) @?= True ++test_minNormal = testGroup "minNormal"+    [ testCase "D" (go (minNormal :: D))+    , testCase "F" (go (minNormal :: F))+    ]+    where+        go n = let (e,_) = floatRange (undefined `asTypeOf` n)+               in  n @?= encodeFloat 1 (e-1)+++test_maxFinite = testGroup "maxFinite"+    [ testCase "D" (go (maxFinite :: D))+    , testCase "F" (go (maxFinite :: F))+    ]+    where+        go n = let r     = floatRadix  (undefined `asTypeOf` n)+                   d     = floatDigits (undefined `asTypeOf` n)+                   (_,e) = floatRange  (undefined `asTypeOf` n)+               in  n @?= encodeFloat (r^d-1) (e-d)+++test_epsilon = testGroup "epsilon"+    [ testCase "D" (go (epsilon :: D))+    , testCase "F" (go (epsilon :: F))+    ]+    where+        go n = let d = floatDigits (undefined `asTypeOf` n)+               in  n @?= encodeFloat 1 (1-d)++ -- succIEEE and predIEEE tests ported from tango/math/IEEE.d test_succIEEE = testGroup "succIEEE"     [ testCase "nan D" test_succIEEE_nan_D@@ -561,6 +591,16 @@     maxPayload = maxNaNPayload (undefined :: F)  +test_maxNaNPayload = testGroup "maxNaNPayload"+    [ testCase "D" (go (undefined :: D))+    , testCase "F" (go (undefined :: F))+    ]+    where+        go n = let b = floatRadix  (undefined `asTypeOf` n)+                   d = floatDigits (undefined `asTypeOf` n)+               in  maxNaNPayload n @?= fromIntegral (b^(d-2)-1)++ test_nanPayload = testGroup "nanPayload"     [ testCase "D1" test_nanPayload_D1     , testCase "D2" test_nanPayload_D2@@ -641,6 +681,9 @@  test_IEEE = testGroup "IEEE"     [ test_infinity+    , test_minNormal+    , test_maxFinite+    , test_epsilon     , test_copySign     , test_succIEEE     , test_predIEEE@@ -652,6 +695,7 @@     , test_minNaN     , test_nan     , test_nanWithPayload+    , test_maxNaNPayload     , test_nanPayload     ]