Cody

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!

Solution Stats

70.37% Correct | 29.63% Incorrect
Last solution submitted on Oct 17, 2016

Tags

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

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Join the 15-year community celebration.

Play games and win prizes!

Learn more