From 43ce6e63e418fa998d0254911ea9dc46286b18d4 Mon Sep 17 00:00:00 2001 From: Miha Kralj Date: Mon, 29 Dec 2025 00:02:38 -0800 Subject: [PATCH] Refactor: Enhance ToString method for TValue struct to handle special double values --- lib/core/tvalue/tvalue.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/core/tvalue/tvalue.cs b/lib/core/tvalue/tvalue.cs index 6f6a2d1b..e557b362 100644 --- a/lib/core/tvalue/tvalue.cs +++ b/lib/core/tvalue/tvalue.cs @@ -26,5 +26,15 @@ public readonly record struct TValue(long Time, double Value) public static implicit operator DateTime(TValue tv) => new(tv.Time, DateTimeKind.Utc); [MethodImpl(MethodImplOptions.AggressiveInlining)] - public override string ToString() => $"[{AsDateTime:yyyy-MM-dd HH:mm:ss}, {Value:F2}]"; -} + public override string ToString() + { + string valueStr = Value switch + { + double.PositiveInfinity => ((char)0x221E).ToString(), + double.NegativeInfinity => "-" + (char)0x221E, + _ when double.IsNaN(Value) => "NaN", + _ => Value.ToString("F2") + }; + return $"[{AsDateTime:yyyy-MM-dd HH:mm:ss}, {valueStr}]"; + } +} \ No newline at end of file