Changeset fe68bdf


Ignore:
Timestamp:
Jul 15, 2020, 6:42:22 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:
791028a
Parents:
21baa40
Message:

add reading for int128 values

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/iostream.cfa

    r21baa40 rfe68bdf  
    1010// Created On       : Wed May 27 17:56:53 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul  8 22:14:20 2020
    13 // Update Count     : 1069
     12// Last Modified On : Wed Jul 15 13:47:48 2020
     13// Update Count     : 1101
    1414//
    1515
     
    970970        } // ?|?
    971971
     972        istype & ?|?( istype & is, int128 & i128 ) {
     973                return (istype &)(is | (unsigned int128 &)i128);
     974        } // ?|?
     975
     976        istype & ?|?( istype & is, unsigned int128 & ui128 ) {
     977                char s[40];
     978                bool sign = false;
     979
     980                if ( fmt( is, " %[-]", s ) == 1 ) sign = true;  // skip whitespace, negative sign ?
     981                // If the input is too large, the value returned is undefined. If there is no input, no value is returned
     982                if ( fmt( is, "%39[0-9]%*[0-9]", s ) == 1 ) {   // take first 39 characters, ignore remaining
     983                        ui128 = 0;
     984                        for ( unsigned int i = 0; s[i] != '\0'; i += 1 ) {
     985                                ui128 = ui128 * 10 + s[i] - '0';
     986                        } // for
     987                        if ( sign ) ui128 = -ui128;
     988                } else if ( sign ) ungetc( is, '-' );                   // return minus when no digits
     989                return is;
     990        } // ?|?
    972991
    973992        istype & ?|?( istype & is, float & f ) {
Note: See TracChangeset for help on using the changeset viewer.