Changeset 9adb61d in mainline for uspace/lib/math/generic/floor.c


Ignore:
Timestamp:
2015-09-05T11:50:00Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
996dc042, ba8eecf
Parents:
e6f5766
Message:

Add single-precision variant for all functions. Allow generic implementations to call other functions while selecting the number of bits of precision, but not the implementation (generic or arch-specific).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/math/generic/floor.c

    re6f5766 r9adb61d  
    3434
    3535#include <floor.h>
     36#include <math.h>
    3637#include <mathtypes.h>
    37 #include <trunc.h>
    3838
    39 /** Ceiling (round towards negative infinity)
     39/** Ceiling (round towards negative infinity, 32-bit floating point)
     40 *
     41 * @param val Floating point number.
     42 *
     43 * @return Number rounded towards negative infinity.
     44 */
     45
     46float32_t float32_floor(float32_t val)
     47{
     48        float32_t t;
     49        float32_u v;
     50       
     51        v.val = val;
     52        t = trunc_f32(val);
     53       
     54        if (v.data.parts.sign == 0 || val == t)
     55                return t;
     56        else
     57                return t - 1.0;
     58}
     59
     60/** Ceiling (round towards negative infinity, 64-bit floating point)
    4061 *
    4162 * @param val Floating point number.
     
    5071       
    5172        v.val = val;
    52         t = float64_trunc(val);
     73        t = trunc_f64(val);
    5374       
    5475        if (v.data.parts.sign == 0 || val == t)
Note: See TracChangeset for help on using the changeset viewer.