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

    re6f5766 r9adb61d  
    3636#include <mod.h>
    3737
    38 /** Double precision modulo
     38/** Remainder function (32-bit floating point)
     39 *
     40 * Calculate the modulo of dividend by divisor.
     41 *
     42 * This is a very basic implementation that uses
     43 * division and multiplication (instead of exact
     44 * arithmetics). Thus the result might be very
     45 * imprecise (depending on the magnitude of the
     46 * arguments).
     47 *
     48 * @param dividend Dividend.
     49 * @param divisor  Divisor.
     50 *
     51 * @return Modulo.
     52 *
     53 */
     54float32_t float32_mod(float32_t dividend, float32_t divisor)
     55{
     56        // FIXME: replace with exact arithmetics
     57       
     58        float32_t quotient = trunc_f32(dividend / divisor);
     59       
     60        return (dividend - quotient * divisor);
     61}
     62
     63/** Remainder function (64-bit floating point)
    3964 *
    4065 * Calculate the modulo of dividend by divisor.
     
    5681        // FIXME: replace with exact arithmetics
    5782       
    58         float64_t quotient = trunc(dividend / divisor);
     83        float64_t quotient = trunc_f64(dividend / divisor);
    5984       
    6085        return (dividend - quotient * divisor);
Note: See TracChangeset for help on using the changeset viewer.