为什么我不能在 tcl 中访问 pi 的正确值?

Why can't I access the correct value of pi in tcl?

这是我执行的代码:

C:\intelFPGA.1\quartus\bin64>tclsh86
% puts $tcl_version
8.6
% package require math::constants
1.0.2
% puts [pi]
26576
% puts [PI]
invalid command name "PI"
% puts [math::constants::pi]
invalid command name "math::constants::pi"
% puts [math::constants::constants::pi]
invalid command name "math::constants::constants::pi"

为什么我得到错误的 pi 值?为什么即使我使用 :: 运算符进入数学包也无法访问正确的值?我刚刚安装了 tcl 库,但我仍然遇到问题。

这是一个变量,不是命令:

% puts $::math::constants::pi
3.141592653589793

或者直接导入到你当前的命名空间:

% ::math::constants::constants pi
% puts $pi
3.141592653589793