Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Problem 1275. Find smallest integer type to accommodate your number

MATLAB supports 1-, 2-, 4-, and 8-byte storage for integer data. Find the smallest integer type to accomodate a scalar integer.

E.g.

a = -10;
c = findclass(a)
c =
   'int8'

or

a = 300;
c = findclass(a)
c =
  'uint16'

Always prefer unsigned integer types if the integer is greater than 0!

Tags

Problem Group

Solution Statistics

17 correct solutions 8 incorrect solutions
Last solution submitted on Oct 03, 2014