liu@S ~ % node
Welcome to Node.js v22.14.0.
Type ".help" for more information.
> 0.1+0.3
0.4
> 0.1+0.2
0.30000000000000004
liu@S ~ % python
Python 3.13.3 (main, Apr 9 2025, 07:44:25) [GCC 14.2.1 20250207] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 0.1+0.3
0.4
>>> 0.1+0.2
0.30000000000000004
liu@S ~ % irb
3.3.8 :001 > 0.1+0.3
=> 0.4
3.3.8 :002 > 0.1+0.2
=> 0.30000000000000004
liu@S ~ % cat a.rs
fn main() {
println!("{}", 0.1+0.2);
}
[0 running job(s)] {history#10021} 21:16:39 2025-06-12
liu@S ~ % rustc a.rs
[0 running job(s)] {history#10022} 21:17:41 2025-06-12
liu@S ~ % ./a
0.30000000000000004
liu@S ~ % cat a.cpp
#include <iostream>
int main() {
std::cout<<(0.1+0.2);
}
[0 running job(s)] {history#10035} 21:19:50 2025-06-12
liu@S ~ % g++ a.cpp
[0 running job(s)] {history#10036} 21:19:55 2025-06-12
liu@S ~ % ./a.out
0.3%
3 个赞