Mercurial > hg > octave-terminal
changeset 10898:4a2dabfb078b
randi.m: Check IMAX for class "single" numbers
author | Rik <octave@nomad.inbox5.com> |
---|---|
date | Tue, 17 Aug 2010 17:45:38 -0700 |
parents | dbec9d590756 |
children | 686e3bc432a2 |
files | scripts/ChangeLog scripts/general/randi.m |
diffstat | 2 files changed, 9 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,7 @@ +2010-08-17 Rik <octave@nomad.inbox5.com> + + * general/randi.m: Add IMAX check for class "single" numbers. + 2010-08-15 Rik <octave@nomad.inbox5.com> * general/randi.m: Add new script for random integers.
--- a/scripts/general/randi.m +++ b/scripts/general/randi.m @@ -85,11 +85,14 @@ rclass = "double"; endif - ## FIXME: No check for class "single" if (strfind (rclass, "int")) if (imax > intmax (rclass)) error ("randi: require IMAX < intmax (CLASS)"); endif + elseif (strcmp (rclass, "single")) + if (imax > bitmax (rclass)) + error ("randi: require IMAX < bitmax (CLASS)"); + endif endif ## Limit set by use of class double in rand() if (imax > bitmax) @@ -132,6 +135,7 @@ %!error(randi(0)) %!error(randi([10, 1])) %!error(randi(256, "uint8")) +%!error(randi(2^25, "single")) %!error(randi(bitmax() + 1)) %!error(randi([-1, bitmax()]))