float incr
unknown
csharp
2 years ago
1.1 kB
9
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