Search code examples
rangeoctave

Getting max possible value of integer data type in Octave


I use GNU Octave, version 6.4.0. Is there any command for getting size of usual data classes, at least for integral data types? Really I want to get max possible value for data type of a matrix which is related to an image. For example for an uint8 image such I it must return 256 for argument class(I). I am looking for a builtin command and do not want to write a switch myself.


Solution

  • The intmax() function does what you want for integer types. Either intmax("uint8") or intmax(a) where a is of type uint8 (or any other integer type).

    https://octave.sourceforge.io/octave/function/intmax.html

    A similar function realmax() exists for floating point types.