PB_Truncate函数截取小数点引起的数字错误

参考PB帮助中Truncate函数的说明:

Using Truncate on a computed field      A real number loaded into a floating point register (used for calculation) is represented as precisely as the binary storage will permit. For example, the real number displayed as 2.07 is actually stored as 2.0699999999999997.

Truncating such a number may not give the expected result. To avoid this problem, you can change the initial real data type to long, integer, or decimal, or you can append a constant in the truncate argument: Truncate (x + 0.0000001, n )

 

xg1=dec(left(mpart[8],4))
gonglv=truncate(xg1 / 100,2)

 

注意,这里的xg1如果是int类型的话,就会发生上面的错误,将其类型修改为DEC后,解决!

转载于:https://www.cnblogs.com/wjonjon/archive/2010/07/14/1777023.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
数组函数 Pos() CloseChannel() PrintSetFont() lowerBound() Replace() ExeclRemote() PrintSetSpacing() UpperBound() Right() GetDataDDEOrigin() PrintSetup() RightTrim() GetRemote() PrintText() Blob(大二进制对象)函数 Space() OpenChanner() PrintWindth() Blob() Trim() RespondRemote() PrintX() BlobEdit() Upper() SetRemote() PrintY() BlobMid() StartHotLink() Len() 系统与环境函数 StopHotLink() 窗口操作函数 String() Clipboard() Close() CommandParm() DDE服务器函数 CloseWithReturn() 数据类型检查与转换函数 DoScript() GetCommandDDE() Open() Asc() GetApplication() GetCommandDDEOrigin() OpenSheet() Char() GetEnvironment() GetDataDDE() OpenSheetWithParm() Dec() GetFocus() GetDataOrigin() OpenWithParm() Double() Post() RespondRemote() Integer() ProfileInt() SetDataDDE() 国际化函数 Long() ProfileString() StartServerDDE() IsAllArabic() Real() Restart() StopServerDDE() IsAllHebew() Date() Run() IsAnyArabic() DateTime() Send() 文件操作函数 IsAnyHebrew() IsNumber() SetProfileString() FileClose() IsArabic() IsTime() ShowHelp() FileDelete() IsArabicAndNumbers() Time() SignalError() FileExists() IsHebrew() Yield() FileLength() IsHebrewAndNumbers() 数值计算函数 FileOPen() Reverse() Abs() 日期、时间函数 FileRead() ToAnsi() Ceiling() Day() FileSeek() ToUnicode() Cos() DayName() FileWrite() Exp() DayNumber() GetFileOpenName() 其他函数 Fact() DaysAfter() GetFileSaveName() Beep() Int() Hour() ClassName() Log() Minute() 库管理函数 DebugBreak() logTen() Month() LibraryCreate() IntLow() Max() Now() LibraryDelete() IsValid() Min() RelativeDate() LibraryDirectory() KeyDown() Mod() RelativeTime() LibraryExport() MessageBox() Pi() Second() LibraryImport() PixelsToUnits() Rand() Today() PopulatError() Randomize() Year() 打印函数 RGB() Round() Print() SetNull() Sign() 注册(Registry)函数 PrintBitmap() SetPointer() Sin() RegistryDelete() PrintCancel() SignalError() Sqrt() RegistryGet() PrintClose() UnitsToPixels() Tan() RegistryKeys() PrintDataWindow() Truncate() RegistrySet() PrintDefineFont() RegistryValues() PrintLine() 字符串操作函数 PrintOpen() Fill() 定时函数 PrintOval() Left() CPU() PrintPage() LeftTrim() Idle() PrintRect() Lower() Timer() PrintRoundRect() Match() PrintScreen() Mid() DDE客户函数 PrintSend()

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值