python (65.1k questions)
javascript (44.2k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (12.9k questions)
Pad float with zeros according to maximum length in list
I have a list:
ls = [1.0, 2.11, 3.981329, -15.11]
I want to add zeros to decimal places of each element so that all values have the same length as the value that has maximum length. So the output sho...
Programmer
Votes: 0
Answers: 2
Left zero padded format numbers
I want to format 4-digit numbers with left padded zeros and 5-digit numbers with no leading zeros so when e.g:
I insert 124 it is formatted to 0124.
30 is formatted to 0030.
When number >9999 then...
komplRX
Votes: 0
Answers: 1
How can I pad a series of hyphen-separated numbers each to two digits?
I am fairly new to PowerShell programming, so need help with set of strings I have as described below:
"14-2-1-1"
"14-2-1-1-1"
"14-2-1-1-10"
I want to pad zero to each n...
Mandeep
Votes: 0
Answers: 2
How to make `bc` output a desired number of base-2 binary digits
This outputs 101110
echo "obase=2; 46" | bc
How can I make it output 8 digits, like this? : 00101110
I learned the above usage of bc here: Bash shell Decimal to Binary base 2 conversion
See...
Gabriel Staples
Votes: 0
Answers: 3