Questions tagged [zerofill]
38 questions
576
votes
77 answers
How can I pad a value with leading zeros?
What is the recommended way to zerofill a value in JavaScript? I imagine I could build a custom function to pad zeros on to a typecasted value, but I'm wondering if there is a more direct way to do this?
Note: By "zerofilled" I mean it in the…

Wilco
- 32,754
- 49
- 128
- 160
10
votes
2 answers
How to Create PostgreSQL Leading Zero Sequence (zerofill)
How can I create a leading zero sequence in PostgreSQL?
For MySQL I know it is BIGINT(10) UNSIGNED ZEROFILL AUTO_INCREMENT but in PostgreSQL I can't find an equivalent (only bigserial).
Moreover how can I limit the number of zeroes as BIGINT(10)…

Vasilen Donchev
- 975
- 4
- 14
- 26
7
votes
4 answers
SQL Server Management Studio ZEROFILL
I am trying to add a auto_increment primary key with ZEROFILL with a max size of six.
So it outputs:
000001
000002 etc...
However I am really struggling to achieve this and cant find the answer. How do I set up this column type in SQL Server…

Austin
- 197
- 1
- 1
- 4
6
votes
8 answers
PHP equivalent javascript >>> shift right with zero fill bitwise operators?
May I know how can I do PHP >>> ? Such operators is not available in PHP, but is available in Javascript.
I just managed to discover a function as follow:
function zeroFill($a, $b)
{
$z = hexdec(80000000);
if ($z & $a)
{
…

neobie
- 2,847
- 5
- 27
- 31
6
votes
3 answers
How do I use sprintf to zero fill to a variable length in Perl?
I want to use Perl's sprintf to zerofill a variable.
sprintf("%08d", $var);
But I want to dynamically determine how many digits to zerofill.
How do I replace the "8" in sprintf("%08d", $var) with a variable called $zerofill?

Michael Shnitzer
- 2,465
- 6
- 25
- 34
3
votes
1 answer
Right shift with zero fill operator in Java (>>>) only working with "int" not "byte"
I write a program in Java to use the right shift with zero fill (>>>) operator.
For the following program everything is good.
class First
{
public static void main(String[] args)
{
int b = -1;
int c =…

my name is GYAN
- 1,269
- 13
- 27
3
votes
3 answers
leading zeros in mysql zerofill int field not showing when queried
I have a table with auto increment zerofill ID numbers. When I query the data the IDs lose their leading zeros (i.e. "000529" returns as "529"). Is there a way to preserve the leading zeros, or even generate them back in the query statement? I know…

Evan4623
- 259
- 1
- 4
- 14
3
votes
1 answer
I want an auto incremented column "ID"starting with 001 in mysql-php? Using phpmyadmin how to do that
I want to start my auto incrementation of column from 001,002,003 like that ..plz tell me how to do that..
Using phpMyadmin.
1. ID
2. 001
3. 002
4. 003
5. .
6. .
7. .
like above shown..

sudhakar phad
- 191
- 1
- 3
- 12
2
votes
4 answers
Save blank file in Objective-C
I am working on a code that, among other things, must save a zero-filled file. It can expect to create a file from 10MB to even 1GB blank.
It must be similar to this Unix command:
dd if=/dev/zero of=my_image.dsk count=20480
I could do this one work…

Apollo
- 1,913
- 2
- 19
- 26
2
votes
1 answer
TSQL/MSSQL Select - zero fill integer
I have an SQL select statement:
select pk from items
it returns:
1
2
4
29
8
987654
12313232
Now my boss wants something like:
000001
000002
000004
000029
000008
987654
12313232
He definitely want the output to be six digits minimum (which I think…

kazinix
- 28,987
- 33
- 107
- 157
2
votes
1 answer
How can I zerofill the index of a Sass for loop?
@for $i from 1 through $layer-count {
#layer-#{$i} { background: url('../layers/layer-#{$i}.png'); }
// background images are named layer-0001.png and up
}
There must be a way to achieve this, but I haven't been able to find anything.

bernk
- 1,155
- 2
- 12
- 22
2
votes
1 answer
Concatenate three 4-bit values
I am trying to get the original 12-bit value from from a base15 (edit) string. I figured that I need a zerofill right shift operator like in Java to deal with the zero padding. How do I do this?
No luck so far with the following code:
static string…

badsyntax
- 23
- 3
2
votes
2 answers
Runtime of Initializing an Array Zero-Filled
If I were to define the following array using the zero-fill initialization syntax on the stack:
int arr[ 10 ] = { 0 };
... is the run time constant or linear?
My assumption is that it's a linear run time -- my assumption is only targeting the fact…

Jacob Pollack
- 3,703
- 1
- 17
- 39
2
votes
3 answers
how to ensure mysql column has 4 character
how to ensure mysql column has 4 character ?
Due to using the MATCH function with minimum 4 char, i want my primary key which is a INT to be at least 4 char.
How can i do it ?
eg. 1 will be 0001 in sql table

Fxster
- 189
- 1
- 4
- 13
2
votes
1 answer
Adding zerofill to existing table
I'm trying to add ZEROFILL to an auto-incremented primary ID field in a MySQL database. Here is the code (auto-generated by MySQL Workbench):
ALTER TABLE `database`.`table` CHANGE COLUMN `id` `id` INT(11) ZEROFILL NOT NULL AUTO_INCREMENT
This is…

David Jones
- 10,117
- 28
- 91
- 139