(?????) ?????? ?????? ??? IEEE ????? Floating-Point

?????? ????????? ?????? ?????????
???? ???????: 42980 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

????????? ??????? ??????? ?? ????? ???? confuses ????????? ?????. ??? ?? ???????? ???????? ????? ????? ?? ?????? ??? ????? ??????? ??? ?? ??????? ?? ???? ????? ??????? ??????? ?????? ???? ?????. ???? ??? ?? ???? ?? ????? ?????? ??? ??????? ???? ???? ?? ???? ???????? ??????? ??????? ???? ????? ??? ????? ?????? ??????? ??????.

??????? ????

?????? ???????? ??? ?????

?????? ???? ???? ??????? ?? ?????? 10. ?????? ??????? ???? ????. ????? ?????? ?? ??????? ??????? traditionally ?????? 10 ?? ?? ????? fingers 10 ??????? ????? counting ??? ?????????.

??? 532.25 ???????? ?????? (?????? 10) ???? ???????:
   (5 * 10^2) + (3 * 10^1) + (2 * 10^0) + (2 * 10^-1) + (5 * 10^-2)
       500    +     30     +      2     +     2/10    +    5/100
   _________
   =  532.25
				

?? ???? ??? ????? (2 ???????) ? ???? ?? ???? ??? 2 ????? ?? 10. ??? ???? ??????? ???? ??? 101.01 ???????:
   (1 * 2^2) + (0 * 2^1) + (1 * 2^0) + (0 * 2^-1) + (1 * 2^-2)
       4     +      0    +     1     +      0     +    1/4
   _________
   =  5.25  Decimal
				

??? ??? ????? ????? ????? ?? ????? ?????????

????? ????? ?? ??? ???? ??? ??? ???? ??? ?????? ?????? ???? ????? ?? ????? ??????? ???????. ???? ?????? ????? ????? ??? ????? ??????? ????? (????? ???????) 2 ???? (16 ??) ????? ?? ?? ?????? ????? ???? ??? ???????. ????? ????? ????? ???? 4 ????. ?? ????? ??????? ?????? ??????? ????????. ??? ???? ??????:
    1 Decimal = 1 Binary
    2 Decimal = 10 Binary
   22 Decimal = 10110 Binary, etc.
				

??? ???? ??? ????? ??????? ??????? ???????? ???? ???? ????? ?????. ??????? ????? ????? ???? ??????? ??? ???? ?????? ????? ????? ?????? ??????? ????? ???? ?? ?????? ???? ?????? ? ????? 1. ??? ???? ??????:
   4 Decimal = 0000 0000 0000 0100
               1111 1111 1111 1011     Flip the Bits
   -4        = 1111 1111 1111 1100     Add 1
				

???? ??-1 ???? = & 1111 1111 1111 1111 ?? ????? ? ???? ???? ??? ????? Basic-1 ?? true ???????? (?? ???? = 1). ??? ??????? ?? ???? ????? ??????? ?????? ??????? ???????? ????? ??????? ? ????????. ?????? ?? ?? Basic? ??? ?????? ???????? ??? ????????? ???????? ????? ????? ???????? ??? ???? ????? ?????? ?? ??????? ??????. ????? ??? ???? ???? ?????? ???????.
   CONST TRUE = -1
   CONST FALSE = NOT TRUE
				

???? ?? ????? ??? ?????? ?? ????? ????? ????? ??????? ???? ???????? ???? ???????? ??????? ???? ?? ??????? ???????.

Complications floating-Point

???? ????? ?? ????? ?????? ?????? ?????? ?????? ??? ???? ?????; ??? ???? ??? ??? ???? ??????? ???? ?????. ?? ???????? ?? ??? irrational ?? ?????? 10 ????? ????? irrational ?? ?? ???? ?? ???? ???? ?? 10.

?????? ??? ????? ? ???? ??? ????? ??? ??????? ???? ???? ????? ?? ????? p/q ? ??? ???? q ?? ??? ???? 2? ???? ??????? ?? ??????, ?? ??? ???? ?? ??????.

?? ???? ????? ???? ????? ??? ??????? ??? 0.001 ?????? ?????? ?? ?????. (0.001 ????? ?? ??? ?????? ???? ????? 104 ??)!

??? ???? ??? ?????? ????? ??? ???????
   SUM = 0
   FOR I% = 1 TO 10000
      SUM = SUM + 0.0001
   NEXT I%
   PRINT SUM                   ' Theoretically = 1.0.
				

????? 1.000054 PRINT ??? ?? ??????. ??? ???? ?? ???? 0.001 ?? ????? ????? ??? ???????.

??? ??? ????? ??? ????? ???? ??? ??? ????????? ??? ????? ???????. ???? ?????? ?????? ??? ????? ?????:
   item1# = 69.82#
   item2# = 69.20# + 0.62#
   IF item1# = item2# then print "Equality!"
				

??? ??? NOT ?????? "??????!" ???? ?? ???? ????? 69.82 ?????? ?? ????? ??????? ???? ???? ?????? ???? ???? ?? ??????? ?????? ?????? (?? ?????) ?? ?????? ???? ??? ??????? ?? ???????. ?? ??????? ?????? ??? ?????? ??? ??? ????????? ???? ??????? ??? ?????? ??????? ?? ???. ??? ???? ??????:
   IF (item1# < 69.83#) AND (item1# > 69.81#) then print "Equal"
				

????? ??? ?????? "?????".

????? ?? ????? IEEE

??? ????? QuickBasic ?? MS-DOS ??????? 3.0 ?? ????? MBF (???? ??????? ????? Microsoft) ???????? ??? IEEE (???? ?????? ???????? ? ????????? ???????????) ?? ??????? ?? ???????. QuickBasic ?? MS-DOS 4.0 ?????????? ?????? ??? ??????? IEEE. Microsoft ????? ????? IEEE ?????? ????? ??????? ??????? ?? ????????? ??????? ?? ????? ?? ??????? ???????? ??????? ???????:
  1. ?????? ?? ???????? coprocessors ???????? Intel ?? ????? ??????? IEEE. ?? ???? coprocessors ????? 80 × 87 Intel ?? ????? Microsoft ????? ?????.
  2. ???? interlanguage ??????? ??? ?? Basic C Pascal FORTRAN MASM ???? ?????. ????? ?? ??????? ??????? ???? ???????? ?????? ????? ??????? ?? ??? ??? ???.
  3. ?????? ???????. ?? IEEE ????? ???????? ???????? compilers C ? FORTRAN.
?????? ?????? ????? ??????? IEEE ? MBF ??? ????? ?????:
               Sign Bits   Exponent Bits   Mantissa Bits
               ---------   -------------   -------------
   IEEE        1           11              52 + 1 (Implied)
    MBF        1            8              56
				

?????? ??? ???? ?? ????????? ??? ?????????? ??? IEEE MBF ??????? ??????? ?????? ? ????????? ?? ????? ?????Microsoft ??? ??????? ???????:
   IEEE and floating and point and appnote
				

???? ?? IEEE ???? ???? ?? ?? ???? ???? ???? ???? ?? ?????? ???? ???? ?? ?????. ????? MBF ?? ????? ???? ?? ????? ?????? ???? ???? ?? ???? ???? ??? ???? ????.

?????? Floating-Point ??????

?? ????? ???? ???? ?? ?? ???? ??????? ??????? ???????? ???? ?? ???? ??? ??? ??? ???? ?? ????? ??????? ??????? ?? ??????? ??????. ??? ?? ??? ????? ???? ????? ?????? ???? ???? representable. ????? ????? IEEE ????? ????? ????? ??? "????" ???? representable. ????? ??????? QuickBasic ?? MS-DOS ?? ????? ???????? ??? ????? IEEE.

?????? ?? ?? ???????? ??? ?????? ??????? ???? ???? ????? ?? IEEE ??? ???? ???? ????. ????? ???? ????? ?? ??? ???. ???? ????? ????? ????? representable ?????? ?? 1.0-1.0 ???? ??? ??? ????? ???????? ?????? 0 ?? ?????????.

??? ????? IEEE ???? ?? ??? ????? ????????? ?????? ??? (?????? ??? ??? ???? ??? ???? ??? ??????). ???? ????? ??? ??? ??????? ???? ????? ?????. ????? IEEE ???????? ?????? ??? ???? ???? ??? ???? ?? ??? ????? ?? ????????? ??? ????? ?? ????? ???????? ???? ?? ??? ?????? ??? ???? ??????.

?????? IEEE

??? ????? ????? ??????? ??????? ?? ??????? ?????? ??? [????] ?? ???? ???????:
   X =  Fraction * 2^(exponent - bias)
				

[???] ??? ??????? ?????? ??? ????? ???? ??? ??? ???? ???? ???? ?? ?????? ?????? 1. ???? ???????? ??? ????? ??????? ??? ???? ?? ?? ???? ?? ?????. ??? ????? ???? ?? ????. ????? ?????? ??? ??? ?????? ??????? ???? ??????? ???? ??? ??? ???? ??? ???? ??????? ??????? ???? ??? ?? ????? ? ????? ?????? ?????? ???? ???? ???? ???? ????? ?? 1 ? ????? ????? ??? ?? 1s 0s.

[????????] ?? ???? ???????? ????????? ????? ???????? ??? ????? ???? ??????.

???????? ????? ????? ?? 127 1023 (????) ??????? ????? ????????.

????? 0 ???? ????? ?? ??? ??? ???? 1 (?????) ?????? ??????? ??????. ???? ???? ????? ???? ????? ? ???? ???? ??? ??????.

????? ????? ????

2 = 1 * 2 ^ 1 = 0100 0000 0000 0000... 0000 0000 = hex 4000 0000
???? ?? ????? ?? ????? ? ???? ??????? ?? 0 0000 128 ?? 100 ?? ????? ? ??? 127 ???????? ??? 1. ?? ????? ?????? ??????? 000 (1). 0000... 0000 0000 ????? ????? ??? ????? ???? 1 ? ???????? ??????? ? ???? ????? ?????? ?????? ?? 1.

2 =-1 * 2 ^ 1 = 1100 0000 0000 0000... 0000 0000 = hex 0000 C000
??? +2 ??? ??? ?? ????? ?? ?????. ???? ??? ?????? ???? ????? ??????? ??????? ????? IEEE.

4 = 1 * 2 ^ 2 = 0100 0000 1000 0000... 0000 0000 = hex 4080 0000
????? ?????? ??? ? ???? ???? ?????? ???? (1 0000 129 ?? 100 ?? ??????? ?? ???? biased.

6 = 1.5 * 2 ^ 2 = 0100 0000 1100 0000... = 0000 0000 40 C 0 ?? ???? 0000
???? ??? ????? ?????? ???? ?????? ???--??? 100 (1). 0000... 0000 0000 ????? ???? ??? ????? ?? 1-1/2 (??? ??????? ???? ?? 1/2, 1/4, 1/8 ? ???.).

1 = 1 * 2 ^ 0 = 0011 1111 1000 0000... 0000 0000 = hex 0000 3F80
????? ?????? ??? ???? ?? ?????? ??? 2 ???? ??? ?? 2 ?? 1 1111 127 ?? 011 ?? ?????.

.75 = 1.5 * 2 ^-1 = 0011 1111 0100 0000... 0000 0000 = hex 0000 3F40
?? ???? biased 126 ? 011 1111 ????? ?? 0 ? ????? ?????? ?? 100 (1). 0000... 0000 0000 ?? 1-1/2.

2.5 = 1.25 * 2 ^ 1 = 0100 0000 0010 0000... 0000 0000 = hex 4020 0000
???? ??? 2 ???? ??? ???? ???? ???? 1/4 ??? ????? ?? ????? ??????.

0.1 = 1-6 * 2 ^-4 = 0011 1101 1100 1100... 1100 1101 = hex CCCD 3DCC
1/10 ????? ?? ??? ???? ?? ?????. ????? ?????? ??? ??? ?? 1-6 ???? ???? biased ???? ??? ???? ????? 16 1-6 (??? 011 1101 1 ?? ????? ??????? ?? 123 ???????? ???????). ?? ???? ?????? 123-127 = - 4 ???? ???? ?? ?????? ???? ????? 2 **-4 = 1/16. ???? ??? ??? ????? ????? ?????? ??????? ?? ?? ???. ??? ?????? ???? ??? unrepresentable ??? ???? ??? ???????. (????? 1/10 ? 1/100 ??? representable ?? ?????? ?? ????? ???? ??????? ???? ??? ?? ?????? representable ???????? ??????? 1/3.)

0 = 1.0 * 2 ^-128 = ???? ???????--???? ????.

????? Floating-Point ?????? ??????

???? ??? ????? ??????? ??????? ???????:
  1. ??? ?? ?????? ?????

    ???? ??? ????? ??? ???? ?????? ?? ??? ????? ?? ???? ????????? ?? ????? ??????.

    ????: ????? 0.001 ??? 0.9900 (????? ????)

    ???? ????? 0.001 ?????? ??:
    10100011011011100010111 (1). * 2^(-14+Bias) (??????? 0s ????? 13!)
    ???? ????? 0.9900 ??:
    11111010111000010100011 (1). * 2^(-1+Bias)
    ???? ?????? ????? ??? ???????, ?????? (?????) ?????? ??? ?? ???? ??????. ??? ??? ?? ???? Unnormalized. ????? ??? ????? ??????:
           .000000000000011010001101 * 2^0  <- Only 11 of 23 Bits retained
          +.111111010111000010100011 * 2^0
          ________________________________
           .111111010111011100110000 * 2^0
    
    						
    ??? ???? ??? ?????? ????? ??? ??? ????? ????????? ?????? ??? ?? ?????? ?????? ???????. ??????? ?????? ???????. ????? - ????? ????? ??? ???? ??? ???????? ???? ???? ??????? ?? ??? ?????? ?????? ????.
  2. ??? ????? ??????? ????? ?????
           .1235
          -.1234
           _____
           .0001
    
    						
    ??? ??? ??? ?????. ???? ??? ??? ????? ?? ??? ?? ?????? ??????? ?? ???? ????? ???? ? ?????? ?? ??? ???? ???? ???.
  3. ????? ????? "?" ????? ???? ??????

    ???? ??? ????? ???? ??????? ????? ???? ?? ????? ???? ??? ??? ??????? ?????? ??? ????????.
  4. ??? quantizing

    ???? ??? ?? ??? ??????? ???? ?? ???? ??????? ?? ??????? ?????? ?????? ??????? ??????? ???????.
  5. ???? ??? ???? ????

    ??? ???? ?? ???? ?????? ??? "???? ?????? ???" ?? ???? ?? ???? ??? ???? ????? ??? ????? ??? ?? ?????? ??????:
          A = 112000000
          B = 100000
          C = 0.0009
          X = A - B / C
    
    						
    QuickBasic ?? MS-DOS X ???? ??? ???? 888887 ? ????? ?? ????? ????? 900000.
  6. ??? ?????

    ???? ??? ????? ?? ??????? ??? ????? ????? ??????? ??? ????? ??.

???????

???? ???????: 42980 - ????? ??? ??????: 11/???/1426 - ??????: 3.1
????? ???
  • Microsoft Visual Basic 2.0 Standard Edition
  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 4.0 Standard Edition
  • Microsoft Visual Basic 1.0 Standard Edition
  • Microsoft Visual Basic 2.0 Professional Edition
  • Microsoft Visual Basic 3.0 Professional Edition
  • Microsoft Visual Basic 4.0 Professional Edition
  • Microsoft Visual Basic for MS-DOS
  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 ?? MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft Cinemania 97 Standard Edition
????? ??????: 
kbmt KB42980 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????42980
????? ??????? ?? ????? ???? ?? ????? ???????
?? ????? ????? ?????? ???? ???? ???? ??? ??????? ??? ?? ? ?? ??? ??????? Microsoft ??? ????? ??? ??????? ????? ?????? ?????

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com