Changeset e3272101 in mainline for uspace/lib/c/generic/imath.c


Ignore:
Timestamp:
2019-02-11T14:08:52Z (6 years ago)
Author:
Matthieu Riolo <matthieu.riolo@…>
Children:
d5a89a3
Parents:
aa57bf7
Message:

make ilog10_u64() return an errno_t

The function ilog10_u64() used to return 0
for the value 0. Which is not correct. Either
NaN or -Infinity are correct, but not 0, since
it would be ambiguous with log(1). To ensure this
case the function ilog10_u64() has been changed
to return a errno_t indicating a failure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/imath.c

    raa57bf7 re3272101  
    8181 *
    8282 * @param v Value to compute logarithm from
     83 * @param res Place to store result
     84 * @return EOK on success
    8385 * @return Logarithm value
    8486 */
    85 unsigned ilog10_u64(uint64_t v)
     87errno_t ilog10_u64(uint64_t v, unsigned *res)
    8688{
     89        if (v == 0)
     90                return ERANGE;
     91
    8792        unsigned b;
    8893        unsigned e;
     
    117122        }
    118123
    119         return r;
     124        *res = r;
     125        return EOK;
    120126}
    121127
Note: See TracChangeset for help on using the changeset viewer.