Find the complement of a number in binary - MATLAB Cody - MATLAB Central

Problem 44814. Find the complement of a number in binary

Difficulty:Rate

Input x is a decimal number and output y is the complement of binary representation of x.

For example, x = 10 has the binary representation of 00001010 (Assume, 8-bit binary representation).

[0   0   0   0   1   0   1   0]

And the output is

y = [1   1   1   1   0   1   0   1]

Solution Stats

37.3% Correct | 62.7% Incorrect
Last Solution submitted on May 14, 2025

Problem Comments

Solution Comments

Show comments
PIVlab surpasses 100K all-time File Exchange downloads
During the past twelve months, PIVlab, a MATLAB Community Toolbox for particle...
4
8
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
2
4

Problem Recent Solvers45

Suggested Problems

More from this Author1

Problem Tags

Community Treasure Hunt

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

Start Hunting!