# HG changeset patch # User Rik # Date 1648849048 25200 # Node ID af6623656f5313795e62ef11661040e50fcb241b # Parent a1c2ea6deaa48fa0e8160589536e47de722366ce bitget.m: Clean up function. * bitget.m: Rename output variable to "B" for "bit". Output is capitalized to indicate it could be an array. Rename internal variable "cl" to "cls" for clarity. Rewrite cumbersome "if ((n < 1)(:))" syntax using post logical test forced column conversion to "if (n(:) < 1)". Add comment to BIST test for empty input to clarify what it is testing. Re-order input validation BIST tests for clarity. diff -r a1c2ea6deaa4 -r af6623656f53 scripts/general/bitget.m --- a/scripts/general/bitget.m Fri Apr 01 23:02:18 2022 +0200 +++ b/scripts/general/bitget.m Fri Apr 01 14:37:28 2022 -0700 @@ -24,7 +24,7 @@ ######################################################################## ## -*- texinfo -*- -## @deftypefn {} {@var{C} =} bitget (@var{A}, @var{n}) +## @deftypefn {} {@var{b} =} bitget (@var{A}, @var{n}) ## Return the bit value at position(s) @var{n} of the unsigned integers in ## @var{A}. ## @@ -41,7 +41,7 @@ ## Liberally based of the version by Kai Habel from Octave Forge -function C = bitget (A, n) +function b = bitget (A, n) if (nargin != 2) print_usage (); @@ -88,7 +88,7 @@ error ("bitget: N must be in the range [1,%d]", Amax); endif - C = bitand (A, bitshift (_conv (1), uint8 (n) - uint8 (1))) != _conv (0); + b = bitand (A, bitshift (_conv (1), uint8 (n) - uint8 (1))) != _conv (0); endfunction