float incr
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; }
Leave a Comment