VFP自身精度好像能做到0xFFFFFFFFFFFFF0,再大就有误差。
程序代码:
*n = 0xFFFFFFFFFFFFFFFF *n = 18446744073709551615 *n = 0xFFFFFFFFFFFFF0 n = 72057594037927920 ? n/1024^0, FormatBytes(n/1024^0) ? n/1024^1, FormatBytes(n/1024^1) ? n/1024^2, FormatBytes(n/1024^2) ? n/1024^3, FormatBytes(n/1024^3) ? n/1024^4, FormatBytes(n/1024^4) ? n/1024^5, FormatBytes(n/1024^5) ? n/1024^6, FormatBytes(n/1024^6) FUNCTION FormatBytes(nValue) IF nValue < 1 RETURN "" ENDIF LOCAL i, aUnits[1] ALINES(aUnits, "Byte,KB,MB,GB,TB,PB,EB,ZB,YB", ",") i = INT(LOG(nValue) / LOG(1024)) RETURN TRANSFORM(ROUND(nValue/(1024^i),2)) + " " + aUnits(i+1) ENDFUNC