about summary refs log tree commit diff
path: root/tvix/eval/src
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src')
-rw-r--r--tvix/eval/src/value/mod.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/tvix/eval/src/value/mod.rs b/tvix/eval/src/value/mod.rs
index 99c7ee8647c3..0a430ae08cb3 100644
--- a/tvix/eval/src/value/mod.rs
+++ b/tvix/eval/src/value/mod.rs
@@ -80,11 +80,17 @@ impl Display for Value {
             Value::Bool(true) => f.write_str("true"),
             Value::Bool(false) => f.write_str("false"),
             Value::Integer(num) => f.write_fmt(format_args!("{}", num)),
-            Value::Float(num) => f.write_fmt(format_args!("{}", num)),
             Value::String(s) => s.fmt(f),
             Value::Attrs(attrs) => attrs.fmt(f),
             Value::List(list) => list.fmt(f),
 
+            // Nix prints floats with a maximum precision of 5 digits
+            // only.
+            Value::Float(num) => f.write_fmt(format_args!(
+                "{}",
+                format!("{:.5}", num).trim_end_matches(['.', '0'])
+            )),
+
             // internal types
             Value::AttrPath(_) | Value::Blackhole => f.write_str("internal"),
         }