Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Padding a fixed number with leading zeros up to a fixed length [closed]

Tags:

In Crystal Report using Visual Studio 2010, I am trying a to create a formula for the following scenario:

x = any number (Fixed number of 8 digits, cant be less or greater)

If Length of X is less than 8, pad the required amount of 0's in the front to make its length 8.

Eg:

X = 123 Result of Formula should be 00000123  X = 9 Result of Formula should be 00000009 

Any help will be appreciated. Thanks in advance.

like image 972
aMazing Avatar asked Jun 12 '12 00:06

aMazing


People also ask

How can I pad a value with leading zeros?

To pad an integer with leading zeros to a specific length To display the integer as a decimal value, call its ToString(String) method, and pass the string "Dn" as the value of the format parameter, where n represents the minimum length of the string.

What are padded zeros?

Zero padding is a technique typically employed to make the size of the input sequence equal to a power of two. In zero padding, you add zeros to the end of the input sequence so that the total number of samples is equal to the next higher power of two.

How do you add leading zeros in SAP PI?

Calling the code to add the leading zeroes from the Mapping BAdI. method IF_ARBERP_BADI_OUTB_MAP~MAP_BUS2012_TO_ORDR_OUT.

What is a leading zero example?

A leading zero is any 0 digit that comes before the first nonzero digit in a number string in positional notation. For example, James Bond's famous identifier, 007, has two leading zeros. When leading zeros occupy the most significant digits of an integer, they could be left blank or omitted for the same numeric value.


1 Answers

ToText({table.field},"00000000") is more succinct.

like image 69
craig Avatar answered Sep 18 '22 19:09

craig