Sometime, you may want to format an integer or a long value into a fixed width String. You need to display the value in fixed width especially in reports where you want to keep the numbers in aligned (e.g. 3456 as 0003456 and 1234 as 0001234). Other than that, you may also want to format the integer value for a better visibility. For example, to display integer value as a do … [Read more...]
Java: Format Long Integer Into Hexadecimal String
In software programming, sometime you may want to convert a long integer or integer into hexadecimal string for viewing purpose or also as a text format to be stored in text file or database. The Java API itself does not have a class or function to convert a long into a fixed 16 characters hexadecimal string or an integer into fixed 8 characters hexadecimal string. The … [Read more...]
Java: Format Bytes Array into Hexadecimal String
Sometimes, we may want to format a bytes array into hexadecimal (base-16) format for debugging purpose or for better readability. One byte has 8 bits and one byte can be represent by two hexadecimal characters (0 - 15 and A - F). … [Read more...]
PHP: Format integer into number of decimal places
Previous I have written an article about formating interger into number of decimal places in Java. The main reason to store money value in integer in to prevent loss in precision. For example the actual value for 12.33 in float could be 12.3333333333...; while 1233 in integer is always 1233. Today I will be showing you the same code but in PHP language. I know you can do the … [Read more...]