F
F
Fedorov199772018-10-19 22:18:32
C++ / C#
Fedorov19977, 2018-10-19 22:18:32

How to output a sequence of binary numbers in a range without converting from decimal to binary?

How can you quickly display a sequence of binary numbers in the range (for example
, from 100 to 111) without going from 10 to 2?
Output for range 100-111:
100
101
110
111
The range can be large. The start and end of the range are powers of two in increments of 1 (for example, from 2^20 to 2^21.)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2018-10-19
@gbg

You create an array of characters 0000...0000, and then do the increment operation until you get all the ones 1111...1111.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question