Questions tagged [leading-zero]
276 questions
4
votes
9 answers
Remove leading zero and delimiter char for BigDecimal
Our application can get following numbers:
0.1
0.02
0.003
etc.
These values treated by our code as BigDecimal,as far we operate with money.
There is form on web UI, where user should view these floating parts of prices, transformed to following…

sergionni
- 13,290
- 42
- 132
- 189
4
votes
2 answers
HTML Input Type Number with Leading Zero on Input
I have HTML Input Type=Number with maxlength='6' and I want it to have leading zeros while typing certain numbers. Leading zeros automatically adjusts depending on your number input.
Example:
While typing '12' in the field, it should add leading…

Jorz
- 358
- 5
- 22
4
votes
2 answers
Perl sequence of numbers with leading zeros
Is there some easy way (without sprintf and, of course, printf) to get a list of (001, 002, ... 100) in Perl?
In bash it was something like seq -w 1 100. What about Perl?

Eugene Barsky
- 5,780
- 3
- 17
- 40
4
votes
2 answers
add leading 0 at a specific position in a string (R)
I have a list of strings of this kind:
f<-c("CC 982","RX 112","TR 002","FF 1328")
I need to add a leading 0, as with the str_pad function, at the beginning of the numerical portion, to get to this:
"CC 0982" "RX 0112" "TR 0002" "FF 1328"
For now,…

AVal
- 617
- 2
- 7
- 12
3
votes
1 answer
Converting string with many leading zeros to decimal
How can I convert string which looks like this:
0005.47
to decimal value 5.47.
This value is kept in newStringArray[1] so I did this: Convert.ToDecimal(newStringArray[1])
But as a result I got this value : 547
What's the point here?

MateuszRek
- 59
- 1
- 7
3
votes
2 answers
How to generate a summary statistics table with all relevant decimal places to appear in the resulting table in R?
I have an exceptionally large dataset (50+ Sites, 100+ Solutes) and I would like to quickly generate a summary table of descriptive statistics for the data and be able export it as a .csv file.
Sample code (a very small subset of my data):
Site <-…

Frost_Queen
- 45
- 7
3
votes
6 answers
Remove leading zeros in IP address using Python
Remove unnecessary zeros in IP address:
100.020.003.400 -> 100.20.3.400
001.200.000.004 -> 1.200.0.4
000.002.300.000 -> 0.2.300.0 (optional silly test)
My attempt does not work well in all cases:
import re
ip = re.sub('[.]0+', '.',…

oHo
- 51,447
- 27
- 165
- 200
3
votes
4 answers
How to recognize single digit in string to insert leading zero?
In Python, I have a string with either two digits or one digit:
8 5E 9C 52 30 0
In every one digit in the string, I would like to add a leading zero to it (e.g. convert 5 to 05) and make it two digits.
Thought of splitting, .split(‘ ‘), and checking…

Jo Ko
- 7,225
- 15
- 62
- 120
3
votes
4 answers
Remove leading zeros in middle of string with regex
I have a large number of strings on the format YYYYYYYYXXXXXXXXZZZZZZZZ, where X, Y, and Z are numbers of fix length, eight digits. Now, the problem is that I need to parse out the middle sequence of integers and remove any leading zeroes.…

user7262455
- 33
- 4
3
votes
1 answer
Better way to change pandas date format to remove leading zeros?
DataFrame look like:
OPENED
0 2004-07-28
1 2010-03-02
2 2005-10-26
3 2006-06-30
4 2012-09-21
I converted them to my desired format successfully but it seems very inefficient.
OPENED
0 40728
1 100302
2 51026
3 60630
4 …

anshanno
- 344
- 4
- 21
3
votes
4 answers
Adding leading 0s in r
I have a large data frame that is filled with characters such as:
x <- c("Y188","Y204" ,"Y221","EP121_1" ,"Y233" , "Y248" ,"Y268", "BB2","BB20",
"BB32" ,"BB044" ,"BB056" , "Y234" , "Y249" ,"Y271" ,"BB3", "BB21", "BB33",
"BB045","BB057" ,"Y236",…

Joey Garzarelli
- 33
- 5
3
votes
2 answers
Count or Return Leading 0's in PHP Regex
If I have
$num = '00000567';
I want to use PHP's preg match or split to split off the 0's so I can count them or count the 0's and have the regex return the variable. Can anyone help me out as the net have very few hits about leading 0's and mostly…

JSG
- 390
- 1
- 4
- 13
3
votes
1 answer
c++ Save Int with leading zeros to String, NOT displaying them
I can format an Int to display a number with leading zeros, but I can't figure out how to save an Int with the zeros to a string.
Reason: Loading image files that end in "..0001" "..0002" ... "..0059" etc.
I have this, but it doesn't work:
int…

MLMLTL
- 1,519
- 5
- 21
- 35
3
votes
1 answer
Adding leading zeroes to dataframe column using sprintf in R
I have a dataframe and want the number variable to be four digits long, in order to do this I need to add between 1-3 leading zeroes, the method I chose to do this is the sprintf function, as it is immaterial that the number is converted to…

Jonno Bourne
- 1,931
- 1
- 22
- 45
3
votes
1 answer
Strange behavior in C when calculating sum of digits with leading zeroes
I just wanted to write a minimalistic program in C to calculate the sum of digits of some natural number (the sum of digits is defined as follows: sumOfDigits(123) = 6, sumOfDigits(0) = 0, sumOfDigits(32013) = 9, and so on).
So far, everything is ok…

bhe
- 85
- 6