Questions tagged [zero-padding]

The practice of padding a number (or string) with zeros in order to match an expected number of characters or bytes.

The practice of padding a number (or string) with zeros in order to match an expected number of characters or bytes.

For example, if the expected length of a string is 6, the number '123' could be zero padded as '000123' in order to meet this expected length.

111 questions
-1
votes
3 answers

8 bits representation

My question will be Arduino specific, I wrote a code that turns array of characters (text) into binary string, but the problem is that the binary representation is not 8 bits, its sometimes 7 bits, 6 bits or even 1 bit representation (if you have a…
Abdullah
  • 11
  • 1
-2
votes
1 answer

How to zero pad an f-string?

Like this is how you can 0 pad a format string for i in range(10): zeropad = "Value is{:03}.".format(i) print(zeropad) and you get result as Value is 000 Value is 001 and so on... So, how can i do the same thing with f-strings?? I tried…
-3
votes
2 answers

Java adding "0" at the end of the number

So my problem was such that I had to compute 10^n such that n ~ 10^5. Obviously it wouldn't fit in any data type hence I decided to use a string instead. Finally, I did find the solution in the beginners book…
-4
votes
1 answer

Python: How do add variable length leading zeros to a binary string?

I am looking to add leading zeros to my_string = '01001010' to ensure that a minimum of 'length' bits string, where length >= len(my_string)
-4
votes
3 answers

How can I fix SyntaxError: invalid syntax when trying to pad zeros to a numeric string?

for i in range(1,50): path = if i < 10: url + '0' + str(i) else: url + str(i) df = pd.read_html(path) in this situation, I got SyntaxError: invalid syntax for 'if'. how can I fix this code?
-4
votes
1 answer

Add leading zeros to a string value in C

it's requested that a given string char input_str[5] = "Hello"; must be padded with leading character = 0. so the result will have a fixed length of 10 characters: out_put == "00000Hello". any idea how to do so in C?
Bauerhof
  • 155
  • 11
1 2 3 4 5 6 7
8