Changeset 3b814c3a in mainline


Ignore:
Timestamp:
2018-08-30T19:12:03Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Children:
bbdca54
Parents:
ace1bca4
Message:

Add nearbyint() and PCUT-based tests for present rounding functions.

Files:
4 added
6 edited

Legend:

Unmodified
Added
Removed
  • boot/Makefile.common

    race1bca4 r3b814c3a  
    244244        $(USPACE_PATH)/lib/sif/test-libsif \
    245245        $(USPACE_PATH)/lib/uri/test-liburi \
     246        $(USPACE_PATH)/lib/math/test-libmath \
    246247        $(USPACE_PATH)/drv/bus/usb/xhci/test-xhci \
    247248        $(USPACE_PATH)/app/bdsh/test-bdsh \
  • uspace/lib/c/include/float.h

    race1bca4 r3b814c3a  
    3232// FIXME: <float.h> is freestanding. Just include the compiler-provided file.
    3333
     34#define FLT_MIN __FLT_MIN__
     35#define FLT_DENORM_MIN __FLT_DENORM_MIN__
     36#define FLT_EPSILON __FLT_EPSILON__
     37
    3438#define FLT_MANT_DIG  __FLT_MANT_DIG__
    3539#define DBL_MANT_DIG  __DBL_MANT_DIG__
  • uspace/lib/c/include/math.h

    race1bca4 r3b814c3a  
    312312#define copysignl __builtin_copysignl
    313313
     314#define nextafter __builtin_nextafter
     315#define nextafterf __builtin_nextafterf
     316#define nextafterl __builtin_nextafterl
     317
    314318#endif
    315319
  • uspace/lib/math/Makefile

    race1bca4 r3b814c3a  
    3939        generic/fabs.c \
    4040        generic/fmod.c \
     41        generic/nearbyint.c \
    4142        generic/round.c \
    4243        generic/trig.c \
    4344        generic/trunc.c
    4445
     46TEST_SOURCES = \
     47        test/rounding.c \
     48        test/main.c
     49
    4550include $(USPACE_PREFIX)/Makefile.common
  • uspace/lib/math/generic/round.c

    race1bca4 r3b814c3a  
    4545float roundf(float val)
    4646{
    47         /* If the input is a nan, return a canonical nan. */
    48         if (isnan(val))
    49                 return __builtin_nanf("");
    50 
    5147        const int exp_bias = FLT_MAX_EXP - 1;
    5248        const int mant_bits = FLT_MANT_DIG - 1;
     
    7874double round(double val)
    7975{
    80         /* If the input is a nan, return a canonical nan. */
    81         if (isnan(val))
    82                 return __builtin_nan("");
    83 
    8476        const int exp_bias = DBL_MAX_EXP - 1;
    8577        const int mant_bits = DBL_MANT_DIG - 1;
  • uspace/lib/math/generic/trunc.c

    race1bca4 r3b814c3a  
    5555float truncf(float val)
    5656{
    57         /* If the input is a nan, return a canonical nan. */
    58         if (isnan(val))
    59                 return __builtin_nanf("");
    60 
    6157        const int exp_bias = FLT_MAX_EXP - 1;
    6258        const int mant_bits = FLT_MANT_DIG - 1;
     
    9995double trunc(double val)
    10096{
    101         /* If the input is a nan, return a canonical nan. */
    102         if (isnan(val))
    103                 return __builtin_nan("");
    104 
    10597        const int exp_bias = DBL_MAX_EXP - 1;
    10698        const int mant_bits = DBL_MANT_DIG - 1;
Note: See TracChangeset for help on using the changeset viewer.