Top 60 Oracle Blogs

Recent comments

How Oracle stores numbers internally

Before you proceed, please check out this short article written by Tanel Poder:

In the documentation, you can find the following explanation about the internal numeric format:

Oracle stores numeric data in variable-length format. Each value is stored in scientific notation, with 1 byte used to store the exponent and up to 20 bytes to store the mantissa. The resulting value is limited to 38 digits of precision. Oracle does not store leading and trailing zeros. For example, the number 412 is stored in a format similar to 4.12 x 102, with 1 byte used to store the exponent(2) and 2 bytes used to store the three significant digits of the mantissa(4,1,2). Negative numbers include the sign in their length.

So how to decode a number from hex value, that can be found in a datafile or archivelog?
Let’s take a value c3020102 which is 10001.

The first byte (c3) is exponent… but wait? c3 = 195. And 10^195 would be a little higher than 10001 </p />

    	  	<div class=