Netlogo 监视器中的小数位

Netlogo 监视器中的小数位,netlogo,Netlogo,我已将Netlogo监视器中的小数点设置为4。以0结尾的数字将被截断(3.4500显示为3.45,3.4550显示为3.455)。有没有办法保留4位小数的外观 假设我们定义: to-report zero-pad [n places] let result (word precision n places) if not is-number? position "." result [ set result (word result ".") ] let padding-

我已将Netlogo监视器中的小数点设置为4。以0结尾的数字将被截断(3.4500显示为3.45,3.4550显示为3.455)。有没有办法保留4位小数的外观

假设我们定义:

to-report zero-pad [n places]
  let result (word precision n places)
  if not is-number? position "." result [
    set result (word result ".")
  ]
  let padding-amount position "." result - length result + places + 1
  let padding reduce word fput "" n-values padding-amount [0]
  report (word result padding)
end
让我们看看它是否有效:

observer> show zero-pad 1.2 3
observer: "1.200"
observer> show zero-pad 1.2468 2
observer: "1.25"
看起来不错。因此,现在,在监视器中,不要只写
x
,如果需要小数点后四位,请写下例如
zero pad x 4