# HG changeset patch # User Arun Giridhar # Date 1638450219 18000 # Node ID 391b35ef8b24fb811533ea360900cf1b6e2a27d0 # Parent 181c44079f6c747630bff5a10d3e7f07f2f77b63 nchoosek: Improve warning messages about large outputs (bug #61565). * scripts/specfun/nchoosek.m: Improve warning messages about large outputs. diff -r 181c44079f6c -r 391b35ef8b24 scripts/specfun/nchoosek.m --- a/scripts/specfun/nchoosek.m Wed Dec 01 22:16:33 2021 +0100 +++ b/scripts/specfun/nchoosek.m Thu Dec 02 08:03:39 2021 -0500 @@ -141,8 +141,12 @@ until (isempty (denom)) C = prod (numer, "native"); - if (C > flintmax) - warning ("nchoosek: possible loss of precision"); + if (isfloat (C) && C > flintmax (C)) + warning ("Octave:nchoosek:large-output-float", ... + "nchoosek: possible loss of precision"); + elseif (isinteger (C) && C == intmax (C)) + warning ("Octave:nchoosek:large-output-integer", ... + "nchoosek: result may have saturated at intmax"); endif elseif (k == 0) C = v(zeros (1, 0)); # Return 1x0 object for Matlab compatibility @@ -287,3 +291,4 @@ %!error nchoosek (-100, 45) %!error nchoosek (100.5, 45) %!warning nchoosek (100, 45); +%!warning nchoosek (uint64 (80), uint64 (40));