Changeset bae1e1f in mainline for uspace/app/tester/float/float2.c


Ignore:
Timestamp:
2015-09-01T08:08:47Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
992ffa6
Parents:
1d03e86
Message:

floor() and ceil().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/float/float2.c

    r1d03e86 rbae1e1f  
    3939};
    4040
     41static double results_ceil[OPERANDS] = {
     42        4.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 769.0, 1081.0, -600.0, 1.0
     43};
     44
     45static double results_floor[OPERANDS] = {
     46        3.0, -3.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
     47};
     48
    4149static double results_trunc[OPERANDS] = {
    4250        3.0, -2.0, 100.0, 50.0, -1024.0, 0.0, 768.0, 1080.0, -600.0, 1.0
     
    5967        bool fail = false;
    6068       
     69        for (unsigned int i = 0; i < OPERANDS; i++) {
     70                double res = floor(arguments[i]);
     71                int64_t res_int = (int64_t) (res * PRECISION);
     72                int64_t corr_int = (int64_t) (results_floor[i] * PRECISION);
     73               
     74                if (res_int != corr_int) {
     75                        TPRINTF("Double floor failed (%" PRId64 " != %" PRId64
     76                            ", arg %u)\n", res_int, corr_int, i);
     77                        fail = true;
     78                }
     79        }
     80
     81        for (unsigned int i = 0; i < OPERANDS; i++) {
     82                double res = ceil(arguments[i]);
     83                int64_t res_int = (int64_t) (res * PRECISION);
     84                int64_t corr_int = (int64_t) (results_ceil[i] * PRECISION);
     85               
     86                if (res_int != corr_int) {
     87                        TPRINTF("Double ceil failed (%" PRId64 " != %" PRId64
     88                            ", arg %u)\n", res_int, corr_int, i);
     89                        fail = true;
     90                }
     91        }
     92
    6193        for (unsigned int i = 0; i < OPERANDS; i++) {
    6294                double res = trunc(arguments[i]);
Note: See TracChangeset for help on using the changeset viewer.