------------------------------------------------------------------------- [BUG/PRB.] ADJUST THE PRECISION OF THE FLOATING-POINT CONSTANTS February 2024 ------------------------------------------------------------------------- CCB 1. BUG: There is a test program: *PROC testfloatingpointconst SET DECIMALS TO 2 ?INT(4294967295/16777216) && Displays 256 if SET("DECIMALS")<=3 SET DECIMALS TO 10 ?INT(4294967295/16777216) && Displays 255 if SET("DECIMALS")>=4 RETURN * END OF PROC TESTFLOATINGPOINTCONST. We think they will display 255, but: ?INT(4294967295/16777216) && Displays 256 if SET("DECIMALS")<=3 2. CAUSE: There are some BUGs in the following code. 3. RESOLUTION: We can write some code to fix the BUG. Label51701a :: mov ecx , dword ptr [ Data9370f0 ] ;0x0051701a : 8b0df0709300 mov eax , dword ptr [ Data9393ac ] ;0x00517020 : a1ac939300 add ecx , 02Ch ;0x00517025 : 83c12c mov dword ptr [ Data9370f0 ] , ecx ;0x00517028 : 890df0709300 mov byte ptr [ecx] , 04Eh ;0x0051702e : c6014e movzx edx ,byte ptr [eax] ;0x00517031 : 0fb610 inc eax ;0x00517034 : 40 mov dword ptr [ ecx + 4 ] , edx ;0x00517035 : 895104 movzx edx ,byte ptr [eax] ;0x00517038 : 0fb610 inc eax ;0x0051703b : 40 mov dword ptr [ ecx + 8 ] , edx ;0x0051703c : 895108 add eax , 08h ;0x0051703f : 83c008 fld qword ptr [ eax - 8 ] ;0x00517042 : dd40f8 mov dword ptr [ Data9393ac ] , eax ;0x00517045 : a3ac939300 fstp qword ptr [ ecx + 16 ] ;0x0051704a : dd5910 ; ; ---------------------------------------------------------------------------- ; VFP 9.0 FIX - ADJUST THE PRECISION OF THE FLOATING-POINT CONSTANTS ; February 2024 ; ---------------------------------------------------------------------------- ; CCB ; ; In vfp9 (and vfp6, vfp7, vfp8), sometimes the value of a floating-point constant is relative to SET("DECIMALS"), for example, ; 4294967295/16777216 = 255.99999994039535520 (0x406FFFFFFFE00000) ; SET DECIMALS TO 2 ; 4294967295/16777216 = 255.99??????????????? ; SET DECIMALS TO 6 ; 4294967295/16777216 = 255.999999??????????? ; SET DECIMALS TO 10 ; 4294967295/16777216 = 255.9999999403??????? ; SET DECIMALS TO 15 ; 4294967295/16777216 = 255.999999940395355?? ; In Visual FoxPro Advanced, it will set 15 or more valid digits for the floating-point constants, for example, ; 4294967295/16777216 = 255.99999994039535520 (0x406FFFFFFFE00000) ; SET DECIMALS TO 2 ; 4294967295/16777216 = 255.999999940395????? ; SET DECIMALS TO 6 ; 4294967295/16777216 = 255.999999940395????? ; SET DECIMALS TO 10 ; 4294967295/16777216 = 255.999999940395????? ; SET DECIMALS TO 15 ; 4294967295/16777216 = 255.999999940395355?? ; ; 2024/2/3, by ccb ; cmp dword ptr vfpa_sys9146_data,00h je Label51704d cmp byte ptr [eax],0CCh jne Label51704d cmp dword ptr [ ecx + 8 ],0Fh jge Label51704d sub esp , 08h fld qword ptr [ ecx + 16 ] fld st(0) fabs fldlg2 fxch st(1) fyl2x fld st(0) fistp dword ptr [ esp ] mov eax,dword ptr [ esp ] cmp eax,80000000h je Label51704b and eax,80000000h test eax,eax jne Label51704b mov eax,0 IFDEF RAX push esi lea esi , dword ptr [ Data922438 ] fadd qword ptr [ 8 * eax + esi ] pop esi ELSE fadd qword ptr [ 8 * eax + offset Data922438 ] ENDIF mov eax,0Ah IFDEF RAX push esi lea esi , dword ptr [ Data922438 ] fadd qword ptr [ 8 * eax + esi ] pop esi ELSE fadd qword ptr [ 8 * eax + offset Data922438 ] ENDIF fistp dword ptr [ esp ] mov eax,0Fh sub eax,dword ptr [ esp ] cmp eax,0 jl Label51704c cmp eax,0Fh jg Label51704c cmp eax,dword ptr [ ecx + 8 ] jle Label51704c cmp dword ptr [ ecx + 8 ],00h jne Label51704a inc dword ptr [ ecx + 4 ] Label51704a :: sub eax,dword ptr [ ecx + 8 ] add dword ptr [ ecx + 8 ],eax add dword ptr [ ecx + 4 ],eax cmp dword ptr [ ecx + 4 ],028h jbe Label51704c mov dword ptr [ ecx + 4 ],028h jmp Label51704c Label51704b :: fstp st(0) mov eax,0Fh cmp eax,dword ptr [ ecx + 8 ] jle Label51704c mov dword ptr [ ecx + 8 ],0Fh mov dword ptr [ ecx + 4 ],11h jmp Label51704c Label51704c :: fstp st(0) add esp , 08h jmp Label51704d Label51704d :: ret ;0x0051704d : c3 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_vfp9fix303.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix23.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix24.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix37.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix38.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix97.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix98.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix123.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix124.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix255.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix256.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix257.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix258.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix259.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix260.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix305.asp http://www.baiyujia.com/vfpdocuments/f_vfp9fix306.asp 6. OTHER: For reference only, there is no guarantees. Any questions or suggestions, please send me an email at ccb2000@163.com. |