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

60.29% Correct | 39.71% Incorrect
Last Solution submitted on Nov 05, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers33

Suggested Problems

More from this Author2

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!