float incr
Anonymous
csharp
02/22/2024 8:43 PM
1.5 KB
16
Indexable
public static long CountIncrementations(float delta)
{
long incrementationsCount = 0;
for (float value = 0; ; ++incrementationsCount)
{
float incrementedValue = value + delta;
if (value == incrementedValue)
break;
value = incrementedValue;
}
for (float value = 0; ; ++incrementationsCount)
{
float incrementedValue = value - delta;
if (value == incrementedValue)
break;
value = incrementedValue;
}
return incrementationsCount;
}
public static long CountIncrementations(double delta)
{
long incrementationsCount = 0;
for (double value = 0; ; ++incrementationsCount)
{
double incrementedValue = value + delta;
if (value == incrementedValue)
break;
value = incrementedValue;
}
for (double value = 0; ; ++incrementationsCount)
{
double incrementedValue = value - delta;
if (value == incrementedValue)
break;
value = incrementedValue;
}
return incrementationsCount;
}Editor is loading...
Leave a Comment