Functions | |
endif | if (nargin==2 &&(!isscalar(n)||(floor(n)!=n))) error("k must be a scalar integer") |
endif | if (isa(a,"double")) bmax |
else | if (isa(a,"uint8")) amax |
elseif (isa(a,"uint16")) amax | |
elseif (isa(a,"uint32")) amax | |
elseif (isa(a,"uint64")) amax | |
elseif (isa(a,"int8")) amax | |
elseif (isa(a,"int16")) amax | |
elseif (isa(a,"int32")) amax | |
elseif (isa(a,"int64")) amax | |
else | error ("invalid class %s", class(a)) |
if (any(m< 1)||any(m > amax)) error("n must be in the range [1 | |
!assert (bitcmp(A, Amax), bitor(bitshift(1, Amax-1), bitshift(1, Amax-2))) | |
!assert (bitcmp(A, Amax-1), bitshift(1, Amax-2)) | |
!assert (bitcmp(A, Amax-2), 0) | |
!assert (bitcmp(A, Amax), bitor(bitshift(uint8(1), Amax-1), bitshift(uint8(1), Amax-2))) | |
!assert (bitcmp(A, Amax-1), bitshift(uint8(1), Amax-2)) | |
!assert (bitcmp(A, Amax-2), uint8(0)) | |
!assert (bitcmp(A, Amax), bitor(bitshift(uint16(1), Amax-1), bitshift(uint16(1), Amax-2))) | |
!assert (bitcmp(A, Amax-1), bitshift(uint16(1), Amax-2)) | |
!assert (bitcmp(A, Amax-2), uint16(0)) | |
!assert (bitcmp(A, Amax), bitor(bitshift(uint32(1), Amax-1), bitshift(uint32(1), Amax-2))) | |
!assert (bitcmp(A, Amax-1), bitshift(uint32(1), Amax-2)) | |
!assert (bitcmp(A, Amax-2), uint32(0)) | |
!assert (bitcmp(A, Amax), bitor(bitshift(uint64(1), Amax-1), bitshift(uint64(1), Amax-2))) | |
!assert (bitcmp(A, Amax-1), bitshift(uint64(1), Amax-2)) | |
!assert (bitcmp(A, Amax-2), uint64(0)) | |
Variables | |
function | x |
amax = ceil (log2 (bmax)) | |
endif | bmax = intmax (class (a)) |
else | m = double (n) |
d | |
endif | mask = bitshift (bmax, n - amax) |
endif endfunction!shared | Amax = 8 |
endif endfunction!shared | Bmax |
endif endfunction!shared A | !Amax = 53 |
!Bmax = bitmax | |
!A = bitshift(Bmax,-2) |
!assert | ( | bitcmp(A, Amax-2) | , | |
uint64(0) | ||||
) |
!assert | ( | bitcmp(A, Amax-2) | , | |
uint32(0) | ||||
) |
!assert | ( | bitcmp(A, Amax-2) | , | |
uint16(0) | ||||
) |
!assert | ( | bitcmp(A, Amax-2) | , | |
uint8(0) | ||||
) |
!assert | ( | bitcmp(A, Amax-2) | , | |
0 | ||||
) |
elseif | ( | isa(a,"int64") | ) |
elseif | ( | isa(a,"int32") | ) |
elseif | ( | isa(a,"int16") | ) |
elseif | ( | isa(a,"int8") | ) |
elseif | ( | isa(a,"uint64") | ) |
elseif | ( | isa(a,"uint32") | ) |
elseif | ( | isa(a,"uint16") | ) |
else error | ( | "invalid class %s" | , | |
class(a) | ||||
) |
if | ( | any(m< 1)||any(m > amax) | ) |
else if | ( | isa(a,"uint8") | ) |
endif if | ( | isa(a,"double") | ) |
!A = bitshift(Bmax,-2) |
!shared A !Amax = 53 |
!Bmax = bitmax |
shared A Amax = 8 |
shared Bmax |
d |