Changeset 336 for trunk/thune/math.c

Show
Ignore:
Timestamp:
01/05/07 21:14:50 (2 years ago)
Author:
krobillard
Message:

Thune - Added lshift, rshift. Improved bitset!.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/thune/math.c

    r294 r336  
    386386            break; 
    387387        default: 
    388             ur_throwErr( ur_thread, UR_EX_DATATYPE, 
    389                          "Invalid type for 'maximum" ); 
    390             break; 
    391     } 
     388            ur_throwErr( UR_ERR_DATATYPE, "Invalid type for 'maximum" ); 
     389            break; 
     390    } 
     391} 
     392 
     393 
     394// (int shift-count -- int) 
     395UR_CALL( uc_lshift ) 
     396{ 
     397    UCell* res = ur_s_prev(tos); 
     398    if( ur_is(res, UT_INT) && ur_is(tos, UT_INT) ) 
     399    { 
     400        UR_S_DROP; 
     401        ur_int(res) <<= ur_int(tos); 
     402        return; 
     403    } 
     404    ur_throwErr( UR_ERR_DATATYPE, "Bit shift expected int! int!" ); 
     405} 
     406 
     407 
     408// (int shift-count -- int) 
     409UR_CALL( uc_rshift ) 
     410{ 
     411    UCell* res = ur_s_prev(tos); 
     412    if( ur_is(res, UT_INT) && ur_is(tos, UT_INT) ) 
     413    { 
     414        UR_S_DROP; 
     415        ur_int(res) >>= ur_int(tos); 
     416        return; 
     417    } 
     418    ur_throwErr( UR_ERR_DATATYPE, "Bit shift expected int! int!" ); 
    392419} 
    393420 
     
    782809    { uc_minimum,      "minimum" }, 
    783810    { uc_maximum,      "maximum" }, 
     811    { uc_lshift,       "lshift" }, 
     812    { uc_rshift,       "rshift" }, 
    784813    { uc_to_deg,       "to-deg" }, 
    785814    { uc_to_rad,       "to-rad" },