Thread: Vapoursynth
View Single Post
Old 22nd October 2019, 23:22   #3682  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
PDR, a bit more.

There are a fractional number of binary digits per decimal digit, and although float only precise to 6 [EDIT: significant] digits, there will likely be one or more decimal digits which are not quite correct.

EDIT: Note, below 6 significant digits
Code:
0.921468
  ^^^^^^

1.921468    # Adding 1.0, last digit is not within first 6 significant digits : Note that the extra digit is printed because of the default print format, rather than it being within first 6 significant digits.
^ ^^^^^
Code:
a = 0.921468  # This was probably not exact to begin with

b = a + 1.0

DIGS=32      # Digits to the right of decimal point

BlankClip

RT_DebugF("a=%.*f\nb=%.*f",DIGS,a,DIGS,b)
RT_subtitle("a=%.*f\nb=%.*f",DIGS,a,DIGS,b)

return last
Code:
00000057    0.29118466  [1068] RT_DebugF: a=0.92146801948547363000000000000000
00000058    0.29125640  [1068] RT_DebugF: b=1.92146801948547360000000000000000
EDIT:
Code:
RT_subtitle("a=%.*f\nb=%.*f",DIGS,a,DIGS,b)

Equiv

RT_subtitle("a=%.32f\nb=%.32f",a,b)
EDIT: No reply necessary.

EDIT:
Quote:
There are a fractional number of binary digits per decimal digit
Code:
Function Log2(float n) {
    return Log(n) / Log(2.0)
}

blankclip
DIGS=32      # Digits to the right of decimal point

BitsPerDecDigit = Log2(10.0)
Test10=Pow(2.0,BitsPerDecDigit)
RT_debugF  ("BitsPerDecDigit=%.*f\nTest10         =%.*f",DIGS,BitsPerDecDigit,DIGS,Test10)
RT_Subtitle("BitsPerDecDigit=%.*f\nTest10         =%.*f",DIGS,BitsPerDecDigit,DIGS,Test10)
return last
Code:
00000231    0.29308608  [4064] RT_DebugF: BitsPerDecDigit=3.32192802429199220000000000000000
00000232    0.29313752  [4064] RT_DebugF: Test10         =9.99999904632568360000000000000000
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 28th October 2019 at 01:55.
StainlessS is offline   Reply With Quote