# Float

Raffriff42 (Talk | contribs) (Float audio range notes) |
|||

(6 intermediate revisions by 2 users not shown) | |||

Line 1: | Line 1: | ||

− | Float (or fully IEEE floating point with single precision) is one of the samples | + | ''This page is about the ''Float ''audio format.'' <br> |

+ | :''For the variable type, see [[Script_variables]].'' <br> | ||

+ | :''For the'' <code>Float()</code> ''function, go to [[Internal_functions#Float]].'' <br> | ||

+ | :''For the {{Deep_color}} format, go to [[Float_(color_format)]]'' | ||

+ | |||

+ | |||

+ | '''Float''' (or fully IEEE floating point with single precision) is one of the [[ConvertAudio|AviSynth audio sample formats]]. | ||

+ | |||

+ | The samples of this type have normal values between -1.0 (= 0xBF800000) and +1.0 (= 0x3F800000). Values outside this range are usable as long as the audio remains in Float format, but will create audio clipping if [[ConvertAudio|converted]] to an integer format: 8, 16, 24 or 32 integer bits. For safety, you can call [[Normalize]] before converting from Float to Integer. | ||

+ | |||

+ | ColorBarsHD ## audio format = Float; range -1.0 - +1.0 | ||

+ | Amplify(1000.0) ## range -1000.0 - +1000.0 | ||

+ | Amplify(0.001) ## range -1.0 - +1.0 | ||

+ | ## output: unchanged | ||

+ | |||

+ | ColorBarsHD ## audio format = Float; range -1.0 - +1.0 | ||

+ | Amplify(1000.0) ## range -1000.0 - +1000.0 | ||

+ | ConvertAudioTo16bit ## convert to Integer; severe clipping | ||

+ | Amplify(0.001) ## still clipping | ||

− | |||

The value of such a IEEE-754 number is computed as: sign * 2^exponent * 1.mantissa, using the following scheme: | The value of such a IEEE-754 number is computed as: sign * 2^exponent * 1.mantissa, using the following scheme: | ||

− | [ 1 Sign Bit | 8 Bit Exponent | 23 Bit Mantissa ] | + | <code>[ 1 Sign Bit | 8 Bit Exponent | 23 Bit Mantissa ]</code> |

* The sign bit is 1 (negative) or 0 (positive). | * The sign bit is 1 (negative) or 0 (positive). | ||

* The exponent runs from -127 (00000000) to 0 (0111111) to 128 (11111111). | * The exponent runs from -127 (00000000) to 0 (0111111) to 128 (11111111). | ||

− | * The mantissa m1m2m3 ... means m1/2 + m2/4 + m3/8 + ... in decimal. Sometimes people denote "1.m1m2m3..." as the mantissa (like is done in the converter | + | * The mantissa m1m2m3 ... means m1/2 + m2/4 + m3/8 + ... in decimal. Sometimes people denote "1.m1m2m3..." as the mantissa (like is done in the converter below). |

+ | |||

+ | For an on-line converter between decimal numbers and IEEE 754 floating point, see [http://www.h-schmidt.net/FloatConverter/IEEE754.html here]. | ||

Examples: | Examples: | ||

Line 33: | Line 52: | ||

Sign bit is negative, exponent = 0, 1.mantissa = 1, so the number is -1.0 | Sign bit is negative, exponent = 0, 1.mantissa = 1, so the number is -1.0 | ||

− | source: [http://www.opferman.net/Text/ieee.txt] | + | and |

+ | |||

+ | 0x800000 = 01001011000000000000000000000000 | ||

+ | |||

+ | Sign Bit Exp 1.Mantissa | ||

+ | 0 10010110 00000000000000000000000 | ||

+ | |||

+ | 150 - 127 = 23 1.0 bitshift 23 places | ||

+ | |||

+ | Sign bit is positive, exponent = 23, 1.mantissa = 1, so the number is 8388608 | ||

+ | |||

+ | source: [https://web.archive.org/web/20120728135435/http://www.opferman.net/Text/ieee.txt opferman.net] | ||

[[Category:Glossary]] | [[Category:Glossary]] |

## Latest revision as of 22:25, 28 October 2019

*This page is about the *Float *audio format.*

*For the variable type, see Script_variables.*

*For the*`Float()`

*function, go to Internal_functions#Float.*

*For the Deep Color format, go to Float_(color_format)*

**Float** (or fully IEEE floating point with single precision) is one of the AviSynth audio sample formats.

The samples of this type have normal values between -1.0 (= 0xBF800000) and +1.0 (= 0x3F800000). Values outside this range are usable as long as the audio remains in Float format, but will create audio clipping if converted to an integer format: 8, 16, 24 or 32 integer bits. For safety, you can call Normalize before converting from Float to Integer.

ColorBarsHD ## audio format = Float; range -1.0 - +1.0 Amplify(1000.0) ## range -1000.0 - +1000.0 Amplify(0.001) ## range -1.0 - +1.0 ## output: unchanged

ColorBarsHD ## audio format = Float; range -1.0 - +1.0 Amplify(1000.0) ## range -1000.0 - +1000.0 ConvertAudioTo16bit ## convert to Integer; severe clipping Amplify(0.001) ## still clipping

The value of such a IEEE-754 number is computed as: sign * 2^exponent * 1.mantissa, using the following scheme:

`[ 1 Sign Bit | 8 Bit Exponent | 23 Bit Mantissa ]`

- The sign bit is 1 (negative) or 0 (positive).
- The exponent runs from -127 (00000000) to 0 (0111111) to 128 (11111111).
- The mantissa m1m2m3 ... means m1/2 + m2/4 + m3/8 + ... in decimal. Sometimes people denote "1.m1m2m3..." as the mantissa (like is done in the converter below).

For an on-line converter between decimal numbers and IEEE 754 floating point, see here.

Examples:

0x3F800000 = 00111111100000000000000000000000 (binary, see [1]) Sign Bit Exp 1.Mantissa 0 01111111 00000000000000000000000 127 - 127 = 0 1.0 bitshift 0 places Sign bit is positive, exponent = 0, 1.mantissa = 1, so the number is +1.0

and

0xBF800000 = 10111111100000000000000000000000 Sign Bit Exp 1.Mantissa 1 01111111 00000000000000000000000 127 - 127 = 0 1.0 bitshift 0 places Sign bit is negative, exponent = 0, 1.mantissa = 1, so the number is -1.0

and

0x800000 = 01001011000000000000000000000000 Sign Bit Exp 1.Mantissa 0 10010110 00000000000000000000000 150 - 127 = 23 1.0 bitshift 23 places Sign bit is positive, exponent = 23, 1.mantissa = 1, so the number is 8388608

source: opferman.net