Changeset 39982 in project


Ignore:
Timestamp:
04/13/21 00:21:20 (4 months ago)
Author:
Kon Lovett
Message:

fix bitwise-count (high-order bit could be set so C arg is unsigned)

Location:
release/5/bitwise-utils/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/5/bitwise-utils/trunk/bitwise-utils.egg

    r39979 r39982  
    33
    44((synopsis "Bitwise utilities")
    5  (version "1.2.2")
     5 (version "1.2.3")
    66 (category data)
    77 (author "Kon Lovett")
  • release/5/bitwise-utils/trunk/bitwise-utils.scm

    r39979 r39982  
    124124  (64bit
    125125    (define uword-bitwise-count
    126       (foreign-lambda* unsigned-int ((integer64 n)) "
     126      (foreign-lambda* unsigned-int ((unsigned-integer64 n)) "
    127127        if (0 == n) C_return( (unsigned int) 0 );
    128128        n = COUNT( n, 0 );
     
    132132        n = COUNT( n, 4 );
    133133        n = COUNT( n, 5 );
    134         C_return( (unsigned int) n );")) )
     134        return( n );")) )
    135135  (else ;32bit
    136136    (define uword-bitwise-count
    137       (foreign-lambda* unsigned-int ((integer32 n)) "
     137      (foreign-lambda* unsigned-int ((unsigned-integer32 n)) "
    138138        if (0 == n) C_return( (unsigned int) 0 );
    139139        n = COUNT( n, 0 );
     
    142142        n = COUNT( n, 3 );
    143143        n = COUNT( n, 4 );
    144         C_return( (unsigned int) n );")) ) )
     144        return( n );")) ) )
    145145
    146146#|
     
    156156(define (add-uword-bits c n) (+ c (uword-bitwise-count n)))
    157157
     158;-> (string-length (string-delete #\0 (number->string n 2)))
    158159(define (bitwise-count n)
    159160  (let ((n (bitwise-abs n)))
  • release/5/bitwise-utils/trunk/tests/bitwise-utils-test.scm

    r39979 r39982  
    6868(test 28 (bitwise-count #x-b0000000000000000000000000110000deadbeef))
    6969
     70(test 64 (bitwise-count 12234789487927890421094841580858919801))
     71
    7072(test #b011001100110011001100110011001100110011001100110 (list->integer (integer->list #b011001100110011001100110011001100110011001100110)))
    7173(test #b0 (list->integer (integer->list #b01100110 0)))
Note: See TracChangeset for help on using the changeset viewer.