Skip to content

Commit

Permalink
Add decimal rounding to AverageRoundTrip (#13)
Browse files Browse the repository at this point in the history
* fixes #12 create totalRoundtrip as a double and round the result to two decimal places.

* set totalRoundTrip type to double using value 0d - #13 (comment)

Co-authored-by: James Turner <Turnerj@users.noreply.github.com>
  • Loading branch information
DanielSpindler83 and Turnerj authored May 23, 2022
1 parent c3442c8 commit 4ae287e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Pingalot.Core/PingSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public PingSession(DateTime startTime, DateTime endTime, TimeSpan elapsed, IRead
private void CalculateStatistics()
{
PacketsSent = Requests.Count;
var totalRoundtrip = 0L;
var totalRoundtrip = 0d;

for (var i = 0; i < Requests.Count; i++)
{
Expand Down Expand Up @@ -65,6 +65,7 @@ private void CalculateStatistics()
if (PacketsReceived > 0)
{
AverageRoundtrip = totalRoundtrip / PacketsReceived;
AverageRoundtrip = Math.Round(AverageRoundtrip, 2);
}
else
{
Expand Down

0 comments on commit 4ae287e

Please sign in to comment.