Changeset 7fd71c7 for libcfa/src


Ignore:
Timestamp:
Apr 21, 2020, 8:25:36 PM (4 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
88293c7
Parents:
fd35f76
Message:

more work on manipulators for int128 numbers, begin test file for printing int128 numbers

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    rfd35f76 r7fd71c7  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 11 14:35:35 2020
    13 // Update Count     : 860
     12// Last Modified On : Mon Apr 20 21:55:00 2020
     13// Update Count     : 912
    1414//
    1515
     
    2929#include <complex.h>                                                                    // creal, cimag
    3030} // extern "C"
     31
     32#include <bitmanip.hfa>                                                                 // fms
    3133
    3234
     
    459461\
    460462                if ( f.base == 'b' || f.base == 'B' ) {                 /* bespoke binary format */ \
    461                         int bits;                                                                                                       \
    462                         if ( f.val == (T){0} ) bits = 1;                        /* force at least one bit to print */ \
    463                         else bits = sizeof(long long int) * 8 - __builtin_clzll( f.val ); /* position of most significant bit */ \
    464                         bits = bits > sizeof(f.val) * 8 ? sizeof(f.val) * 8 : bits; \
     463                        int bits = high1( f.val );                                      /* position of most significant bit */ \
     464                        if ( bits == 0 ) bits = 1;                                      /* 0 value => force one bit to print */ \
    465465                        int spaces = f.wd - bits;                                       /* can be negative */ \
    466466                        if ( ! f.flags.nobsdp ) { spaces -= 2; }        /* base prefix takes space */ \
     
    565565                                fmt2.flags.pad0 = fmt2.flags.nobsdp = true;     \
    566566                                if ( f.base == 'b' | f.base == 'B' ) { \
    567                                         if ( f.wd > 64 ) fmt.wd = f.wd - 64; \
    568                                         if ( f.flags.pc && f.pc > 64 ) fmt.pc = f.pc - 64; \
    569                                         fmt2.wd = 64; \
     567                                        if ( fmt.flags.pc && fmt.pc > 64 ) fmt.pc -= 64; \
     568                                        if ( fmt.flags.left ) { \
     569                                                fmt2.wd = fmt.wd; \
     570                                                if ( fmt2.wd <= 64 ) { \
     571                                                        fmt2.wd = 64; \
     572                                                } else { \
     573                                                        if ( fmt.pc > 0 ) { \
     574                                                                fmt2.wd -= fmt.pc; \
     575                                                        } else { \
     576                                                                fmt2.wd = fmt.wd - high1( msig ); \
     577                                                        } /* if */ \
     578                                                        if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; \
     579                                                        if ( fmt2.wd < 0 ) fmt2.wd = 0; \
     580                                                        fmt2.flags.left = true; \
     581                                                        fmt.wd = 0; \
     582                                                } /* if */ \
     583                                                printf( "left %d %d %x\n", f.wd, f.pc, f.all ); \
     584                                                printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
     585                                        } else { \
     586                                                fmt2.wd = 64; \
     587                                                if ( fmt.wd > 64 ) fmt.wd -= 64; \
     588                                                printf( "left %d %d %x\n", f.wd, f.pc, f.all ); \
     589                                                printf( "left %d %d %x\n", fmt.wd, fmt.pc, fmt.all ); \
     590                                        } /* if */ \
     591                                        fmt2.pc = 64; fmt2.flags.pc = true;     \
     592                                        printf( "left %d %d %x\n", fmt2.wd, fmt2.pc, fmt2.all ); \
    570593                                        (ostype &)(os | fmt | "" | fmt2); \
    571594                                } else if ( f.base == 'o' ) { \
    572                                         fmt.val = (unsigned long long int)fmt.val >> 2; \
    573                                         if ( f.wd > 21 ) fmt.wd = f.wd - 21; \
    574                                         if ( f.flags.pc && f.pc > 21 ) fmt.pc = f.pc - 21; \
    575                                         fmt2.wd = 1; \
    576                                         fmt2.val = ((msig & 0x3) << 1) + 1; \
    577                                         (ostype &)(os | fmt | "" | fmt2); \
    578                                         sepOff( os ); \
    579                                         fmt2.wd = 21; \
    580                                         fmt2.val = lsig & 0x7fffffffffffffff; \
    581                                         (ostype &)(os | fmt2); \
     595                                        if ( fmt.flags.pc && fmt.pc > 21 ) fmt.pc -= 21; \
     596                                        if ( fmt.flags.left ) { \
     597                                                fmt2.wd = fmt.wd; \
     598                                                if ( fmt2.wd <= 21 ) { \
     599                                                        fmt2.wd = fmt2.pc = 16; fmt2.flags.pc = true; \
     600                                                } else { \
     601                                                } /* if */ \
     602                                        } else { \
     603                                                fmt.val = (unsigned long long int)fmt.val >> 2; \
     604                                                if ( fmt.wd > 21 ) fmt.wd -= 21; \
     605                                                if ( ! fmt.flags.nobsdp ) { if ( fmt.pc < fmt.wd ) fmt.wd -= 1; else fmt.pc -= 1; } \
     606                                                fmt2.wd = 1; \
     607                                                fmt2.val = ((msig & 0x3) << 1) + 1; \
     608                                                (ostype &)(os | fmt | "" | fmt2); \
     609                                                sepOff( os ); \
     610                                                fmt2.wd = 21; \
     611                                                fmt2.val = lsig & 0x7fffffffffffffff; \
     612                                                (ostype &)(os | fmt2); \
     613                                        } /* if */ \
    582614                                } else { \
    583                                         if ( f.flags.left ) { \
    584                                                 if ( f.wd > 16 ) fmt2.wd = f.wd - 16; \
    585                                                 fmt.wd = 16; \
     615                                        if ( fmt.flags.pc && fmt.pc > 16 ) fmt.pc -= 16; \
     616                                        if ( fmt.flags.left ) { \
     617                                                fmt2.wd = fmt.wd; \
     618                                                if ( fmt2.wd <= 16 ) { \
     619                                                        fmt2.wd = 16; \
     620                                                } else { \
     621                                                        if ( fmt.pc > 0 ) { \
     622                                                                fmt2.wd -= fmt.pc; \
     623                                                        } else { \
     624                                                                fmt2.wd = fmt.wd - ceiling2( high1( msig ), 4 ) / 4; \
     625                                                        } /* if */ \
     626                                                        if ( ! fmt.flags.nobsdp ) fmt2.wd -= 2; \
     627                                                        if ( fmt2.wd < 0 ) fmt2.wd = 0; \
     628                                                        fmt2.flags.left = true; \
     629                                                        fmt.wd = 0; \
     630                                                } /* if */ \
    586631                                        } else { \
    587                                                 if ( f.wd > 16 ) fmt.wd = f.wd - 16; \
    588                                                 if ( f.flags.pc && f.pc > 16 ) fmt.pc = f.pc - 16; \
    589632                                                fmt2.wd = 16; \
     633                                                if ( fmt.wd > 16 ) fmt.wd -= 16; \
    590634                                        } /* if */ \
     635                                        fmt2.pc = 16; fmt2.flags.pc = true; \
    591636                                        (ostype &)(os | fmt | "" | fmt2); \
    592637                                } /* if */ \
Note: See TracChangeset for help on using the changeset viewer.