-----------------------------------------------------------------------------------------------------------------
                      [BUG/PRB.] VFP 9.0 FIX - THE DISPLAY WIDTH AND THE DECIMAL PLACES OF NUMERIC DATA FOR NUMERIC OPERATORS
                                 January 2024
                 -----------------------------------------------------------------------------------------------------------------
                                    CCB



1. BUG:

     In vfp9 (and vfp6, vfp7, vfp8), for numeric operators,
     usually the maximum display width of numeric data is 40 (0x28), the maximum decimal places of numeric data is 18 (0x12),
     but somtimes the display width of numeric data is a negative integer, or the decimal places of numeric data is a negative integer.

     The bug occurs in the following operators and functions:
     addition (+) operator
     subtraction (-) operator
     multiplication (*) operator
     division (/) operator
     modulus (%) operator or MOD() function
     ROUND() function

     In Visual FoxPro Advanced, for numeric operators,
     the maximum display width of numeric data is 40 (0x28), the maximum decimal places of numeric data is 18 (0x12),
     and there is no the bug.


2. CAUSE:

     There are some BUGs in the following code.


3. RESOLUTION:

     We can write some code to fix the BUG.

     Label420ee3 ::
             je Label58fc5e                                                  ;0x00420ee3 :        0f8475ed1600
             cmp eax , 04949h                                                ;0x00420ee9 :        3d49490000
             jg Label525e70                                                  ;0x00420eee :        0f8f7c4f1000
             jne Label420f26                                                 ;0x00420ef4 :        7530
             lea edx ,  dword ptr [ ebx + 12 ]                               ;0x00420ef6 :        8d530c
             lea ecx ,  dword ptr [ esi + 12 ]                               ;0x00420ef9 :        8d4e0c
             call Fun525dbc                                                  ;0x00420efc :        e8bb4e1000
             test eax , eax                                                  ;0x00420f01 :        85c0
             jne Label58fc85                                                 ;0x00420f03 :        0f857ced1600
             mov  eax , dword ptr [ esi + 4 ]                                ;0x00420f09 :        8b4604
             mov  ebx , dword ptr [ ebx + 4 ]                                ;0x00420f0c :        8b5b04
             cmp eax , ebx                                                   ;0x00420f0f :        3bc3


     ;
     ;                 ------------------------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE DISPLAY WIDTH AND THE DECIMAL PLACES OF NUMERIC DATA FOR NUMERIC OPERATORS
     ;                                February 2023
     ;                 ------------------------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9 (and vfp6, vfp7, vfp8), for the addition (+) operator,
     ; usually the maximum display width of numeric data is 40 (0x28), the maximum decimal places of numeric data is 18 (0x12),
     ; but somtimes the display width of numeric data is a negative integer, or the decimal places of numeric data is a negative integer.
     ; In Visual FoxPro Advanced, for the addition (+) operator,
     ; the maximum display width of numeric data is 40 (0x28), the maximum decimal places of numeric data is 18 (0x12),
     ; and there is no the bug.
     ;
     ; 2023/2/10, by ccb
     ;

     ;         jle Label5067d4                                                 ;0x00420f11 :        0f8ebd580e00
             jbe Label5067d4                                                 ;0x00420f11 :        0f8ebd580e00


     Label420f17 ::
             mov  dword ptr [ esi + 4 ] , eax                                ;0x00420f17 :        894604
             inc eax                                                         ;0x00420f1a :        40
             cmp eax , 028h                                                  ;0x00420f1b :        83f828


     ;
     ;                 ------------------------------------------------------------------------------------------------------
     ;                      VFP 9.0 FIX - THE DISPLAY WIDTH AND THE DECIMAL PLACES OF NUMERIC DATA FOR NUMERIC OPERATORS
     ;                                February 2023
     ;                 ------------------------------------------------------------------------------------------------------
     ;                                     CCB
     ;
     ; In vfp9 (and vfp6, vfp7, vfp8), for the addition (+) operator,
     ; usually the maximum display width of numeric data is 40 (0x28), the maximum decimal places of numeric data is 18 (0x12),
     ; but somtimes the display width of numeric data is a negative integer, or the decimal places of numeric data is a negative integer.
     ; In Visual FoxPro Advanced, for the addition (+) operator,
     ; the maximum display width of numeric data is 40 (0x28), the maximum decimal places of numeric data is 18 (0x12),
     ; and there is no the bug.
     ;
     ; 2023/2/10, by ccb
     ;

     ;         jnl Label58fc91                                                 ;0x00420f1e :        0f8d6ded1600
             jnb Label58fc91                                                 ;0x00420f1e :        0f8d6ded1600


             jmp Label420eab                                                 ;0x00420f24 :        eb85


4. APPLIES TO:

     VFP 6.0.8167.0
     VFP 6.0.8961.0 (SP5)

     VFP 7.0.0.9262
     VFP 7.0.0.9465 (SP1)

     VFP 8.0.0.2521
     VFP 8.0.0.3117 (SP1)

     VFP 9.0.0.2412
     VFP 9.0.0.3504 (SP1)
     VFP 9.0.0.4611 (SP2)
     VFP 9.0.0.5015 (SP2)
     VFP 9.0.0.5411 (SP2)
     VFP 9.0.0.5721 (SP2)
     VFP 9.0.0.5815 (SP2)
     VFP 9.0.0.6303 (SP2)
     VFP 9.0.0.6602 (SP2)
     VFP 9.0.0.7423 (SP2)

     The bug has been fixed in VFP Advanced.


5. REFERENCE WEBSITES:

     1, baiyujia.com:
     http://www.baiyujia.com
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix86.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix105.asp
     http://www.baiyujia.com/vfpdocuments/f_vfp9fix243.asp


6. OTHER:

     For reference only, there is no guarantees.

     Any questions or suggestions, please send me an email at ccb2000@163.com.