Changeset 3bacee1 in mainline for uspace/lib/c/generic/double_to_str.c


Ignore:
Timestamp:
2018-04-12T16:27:17Z (7 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3cf22f9
Parents:
76d0981d
git-author:
Jiri Svoboda <jiri@…> (2018-04-11 19:25:33)
git-committer:
Jiri Svoboda <jiri@…> (2018-04-12 16:27:17)
Message:

Make ccheck-fix again and commit more good files.

File:
1 edited

Legend:

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

    r76d0981d r3bacee1  
    5656static bool is_normalized(fp_num_t num)
    5757{
    58         assert(8*sizeof(num.significand) == significand_width);
     58        assert(8 * sizeof(num.significand) == significand_width);
    5959
    6060        /* Normalized == most significant bit of the significand is set. */
     
    147147/** Returns the interval [low, high] of numbers that convert to binary val. */
    148148static void get_normalized_bounds(ieee_double_t val, fp_num_t *high,
    149         fp_num_t *low, fp_num_t *val_dist)
     149    fp_num_t *low, fp_num_t *val_dist)
    150150{
    151151        /*
     
    181181
    182182        val_dist->significand =
    183                 val_dist->significand << (val_dist->exponent - high->exponent);
     183            val_dist->significand << (val_dist->exponent - high->exponent);
    184184        val_dist->exponent = high->exponent;
    185185}
     
    198198 */
    199199static void calc_scaled_bounds(ieee_double_t val, fp_num_t *scaled_upper_bound,
    200         fp_num_t *bounds_delta, fp_num_t *val_dist, int *scale)
     200    fp_num_t *bounds_delta, fp_num_t *val_dist, int *scale)
    201201{
    202202        fp_num_t upper_bound, lower_bound;
     
    251251/** Rounds the last digit of buf so that it is closest to the converted number.*/
    252252static void round_last_digit(uint64_t rest, uint64_t w_dist, uint64_t delta,
    253         uint64_t digit_val_diff, char *buf, int len)
     253    uint64_t digit_val_diff, char *buf, int len)
    254254{
    255255        /*
     
    277277        bool next_in_val_rng = cur_greater_w && (rest + digit_val_diff < delta);
    278278        /* Rounding down by one would bring buf closer to the processed number. */
    279         bool next_closer = next_in_val_rng
    280                 && (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);
     279        bool next_closer = next_in_val_rng &&
     280            (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);
    281281
    282282        /* Of the shortest strings pick the one that is closest to the actual
     
    291291                cur_greater_w = rest < w_dist;
    292292                next_in_val_rng = cur_greater_w && (rest + digit_val_diff < delta);
    293                 next_closer = next_in_val_rng
    294                         && (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);
     293                next_closer = next_in_val_rng &&
     294                    (rest + digit_val_diff < w_dist || rest - w_dist < w_dist - rest);
    295295        }
    296296}
     
    326326 */
    327327static int gen_dec_digits(fp_num_t scaled_upper, fp_num_t delta,
    328         fp_num_t val_dist, int scale, char *buf, size_t buf_size, int *dec_exponent)
     328    fp_num_t val_dist, int scale, char *buf, size_t buf_size, int *dec_exponent)
    329329{
    330330        /*
     
    411411                        /* Of the shortest representations choose the numerically closest. */
    412412                        round_last_digit(remainder, val_dist.significand, delta.significand,
    413                                 (uint64_t)div << (-one.exponent), buf, len);
     413                            (uint64_t)div << (-one.exponent), buf, len);
    414414                        return len;
    415415                }
     
    457457        /* Of the shortest representations choose the numerically closest one. */
    458458        round_last_digit(frac_part, val_dist.significand, delta.significand,
    459                 one.significand, buf, len);
     459            one.significand, buf, len);
    460460
    461461        return len;
     
    504504 */
    505505int double_to_short_str(ieee_double_t ieee_val, char *buf, size_t buf_size,
    506         int *dec_exponent)
     506    int *dec_exponent)
    507507{
    508508        /* The whole computation assumes 64bit significand. */
     
    524524
    525525        calc_scaled_bounds(ieee_val, &scaled_upper_bound,
    526                 &delta, &val_dist, &scale);
     526            &delta, &val_dist, &scale);
    527527
    528528        int len = gen_dec_digits(scaled_upper_bound, delta, val_dist, scale,
    529                 buf, buf_size, dec_exponent);
     529            buf, buf_size, dec_exponent);
    530530
    531531        assert(len <= MAX_DOUBLE_STR_LEN);
     
    554554 */
    555555static int gen_fixed_dec_digits(fp_num_t w_scaled, int scale, int signif_d_cnt,
    556         int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)
     556    int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)
    557557{
    558558        /* We'll produce at least one digit and a null terminator. */
     
    608608        int rem_signif_d_cnt = signif_d_cnt;
    609609        int rem_frac_d_cnt =
    610                 (frac_d_cnt >= 0) ? (kappa - scale + frac_d_cnt) : INT_MAX;
     610            (frac_d_cnt >= 0) ? (kappa - scale + frac_d_cnt) : INT_MAX;
    611611
    612612        /* Produce decimal digits for the integral part of w_scaled. */
     
    752752 */
    753753int double_to_fixed_str(ieee_double_t ieee_val, int signif_d_cnt,
    754         int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)
     754    int frac_d_cnt, char *buf, size_t buf_size, int *dec_exponent)
    755755{
    756756        /* The whole computation assumes 64bit significand. */
     
    780780        /* Produce decimal digits from the scaled number. */
    781781        int len = gen_fixed_dec_digits(w_scaled, scale, signif_d_cnt, frac_d_cnt,
    782                 buf, buf_size, dec_exponent);
     782            buf, buf_size, dec_exponent);
    783783
    784784        assert(len <= MAX_DOUBLE_STR_LEN);
Note: See TracChangeset for help on using the changeset viewer.