This answer presents a hypothesis fitting available information (excluding inconsistencies in the documentation linked below), that FLOAT(x) is a floating-point type with ⌈x log10 2⌉ decimal digits in its significand.
The examples in the question appear to come from this page pointed out by user gsalem, or a version of it.
First, we note the page discusses a NUMBER type, parameterized by a precision p and a scale s. The precision p is a number of decimal digits. Specifically, the page says it is “the maximum number of significant decimal digits.” (The page suggests the actual storage may use base 100, where it mentions “precision of up to 20 base-100 digits.” Software might provide decimal behavior while using base 100. For example, with three decimal digits of precision, the first base-100 digit could be any digit from 0 to 99, while the second digit would be limited to 0, 10, 20, 30, 40, 50, 60, 70, 80, or 90.)
The page then shows a number of examples that are consistent with the above. I note it appears to be a fixed-point format; the scale s is not a bound on a floating exponent but is a fixed exponent for the format. For example, converting 123.89 to NUMBER(6, -2) yields 100, which is consistent with a format containing six significant digits with the lowest in the 102 position (the - of -2 meaning to the left of the decimal point). That is, this format would have decimal numerals in the form abcdef00, so the closest it can get to 123.89 is 00000100, or 100.
Next, the page discusses the FLOAT type, which it says is a “subtype” of NUMBER. It also says “It can be specified with or without precision, which has the same definition it has for NUMBER” (emphasis added). But this is clearly false: If FLOAT(5) meant 5 decimal digits, as it did for NUMBER, then 1.23, 7.89, 12.79, and 123.45 could all be represented in FLOAT(5), but the examples show they are not.
Cryptically, the page says “To convert from binary to decimal precision, multiply n by 0.30103.” It has neither introduced n nor explained what binary precision we are converting from, nor where the result of this conversion is used. We will come back to this.
The page gives us these examples:
| Original Value |
Converted to NUMBER(5, 2) |
Converted to FLOAT(5) |
| 1.23 |
1.23 |
1.2 |
| 7.89 |
7.89 |
7.9 |
| 12.79 |
12.79 |
13 |
| 123.45 |
123.45 |
120 |
As explanation, the page states “the FLOAT value must be truncated so that its significant digits do not require more than 5 binary digits. Thus 123.45 is rounded to 120, which has only two significant decimal digits, requiring only 4 binary digits.” However, this explanation is inadequate. Converting 123.45 to no more than 5 binary digits would allow the closer value 124, which is 11111002 in binary, which has exactly 5 significant binary digits.
Further, converting 7.89 to no more than 5 binary digits cannot yield 7.9. The closest representable values are 1000.02 (decimal 8) and 111.112 (decimal 7.75).
Therefore, we conclude this discussion of binary digits as a limit explaining the examples is rubbish.
I propose this hypothesis: FLOAT(x) provides a type with ⌈x log10 2⌉ decimal digits (in code, ceil(x*log(2)/log(10))). Thus FLOAT(5) provides ⌈5 log10 2⌉ = ⌈1.505…⌉ = 2 decimal digits. Observe this fits the examples given in the page: 1.23, 7.89, 12.79, and 123.45 each map to the closest decimal numeral with two significant digits, 1.2, 7.9, 13, and 120.
Also note this is not a fixed-point format. Each of the numbers has two significant decimal digits, but they appear at varying positions: 100 to 10−1 in the first two, 101 to 100 in the third, and 102 to 101 in the fourth. This is a floating-point format, which is consistent with the page’s statement that “Scale cannot be specified, but is interpreted from the data” and inconsistent with the statement that “The FLOAT data type is a subtype of NUMBER.” It is not a subtype but is a similar format (decimal with a fixed number of digits) with a floating exponent instead of a fixed exponent.
120, also. A different page (not Oracle's) claims that SQL typesFLOAT(1)throughFLOAT(24)map to IEEE754 single precision, while 25-53 map to double.