chore(Core/Misc): update floor and ceil to std (#19837)

This commit is contained in:
Kitzunu
2024-09-03 13:01:00 +02:00
committed by GitHub
parent de2bcbdabf
commit 9af86553c5
10 changed files with 28 additions and 20 deletions

View File

@@ -20,6 +20,7 @@
#include "Log.h"
#include "Timer.h"
#include <algorithm>
#include <cmath>
#include <iterator>
// create instance
@@ -87,12 +88,12 @@ uint32 UpdateTime::GetPercentile(uint8 p)
double index = (double(p) / 100.0) * (GetDatasetSize() - 1);
// If the index is an integer, return the value at that index
if (index == floor(index))
if (index == std::floor(index))
return _orderedUpdateTimeDataTable[index];
// Otherwise, perform linear interpolation
int lowerIndex = floor(index);
int upperIndex = ceil(index);
int lowerIndex = std::floor(index);
int upperIndex = std::ceil(index);
double fraction = index - lowerIndex;
return _orderedUpdateTimeDataTable[lowerIndex] * (1 - fraction) + _orderedUpdateTimeDataTable[upperIndex] * fraction;