Infinite circular slider / rotary dial input

I want to implement an input that consists of a circle that the user would rotate like a dial to increment/decrement an associated number. I’ve been able to find a few posts about how to make a dial visually rotate when used like this, and I think I could figure out how to get a number from the resulting angle if the dial was limited to < 360 degrees of spin, but I want the user to be able to keep rotating the dial indefinitely to continue raising or lowering the associated number. I’m not entirely sure how to approach this, I’d appreciate any help to get started.

Thank you!

float prevDegrees = 0;
float cumulativeValue = 0;

// assuming the "degrees" is guaranteed in the the range [-180, 180].
void onNewDegrees(float degrees) {
    float diff = degrees - prevDegrees;
    if (diff > 180f) {
      diff -= 360f;
    }
    else if (diff < -180f) {
      diff += 360f;
    }

    cumulativeValue += diff;

    prevDegrees = degrees;
}