Changeset 9adb61d in mainline for uspace/lib/math/generic/ceil.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/ceil.c

    re6f5766 r9adb61d  
    3434
    3535#include <ceil.h>
     36#include <math.h>
    3637#include <mathtypes.h>
    37 #include <trunc.h>
    3838
    39 /** Ceiling (round towards positive infinity)
     39/** Ceiling (round towards positive infinity, 32-bit floating point)
     40 *
     41 * @param val Floating point number.
     42 *
     43 * @return Number rounded towards positive infinity.
     44 */
     45float32_t float32_ceil(float32_t val)
     46{
     47        float32_u t;
     48        float32_u v;
     49        float32_u r;
     50       
     51        v.val = val;
     52        t.val = trunc_f32(val);
     53       
     54        if (v.data.parts.sign == 1 || val == t.val) {
     55                r = t;
     56        } else {
     57                r.val = t.val + 1.0;
     58        }
     59       
     60        return r.val;
     61}
     62
     63/** Ceiling (round towards positive infinity, 64-bit floating point)
    4064 *
    4165 * @param val Floating point number.
     
    5074       
    5175        v.val = val;
    52         t.val = float64_trunc(val);
     76        t.val = trunc_f64(val);
    5377       
    5478        if (v.data.parts.sign == 1 || val == t.val) {
Note: See TracChangeset for help on using the changeset viewer.