I know this should be avoided, but unfortunately I have to use integers and floating point (double) in a mixed calculation. The title already states the question:
Is the following code guaranteed to work (no assert) with all c++ floating point implementations regardless the numeric values as long as there is no overflow ?
Edit: Forgot to mention that the values are always positive
double realSplit = seg.squareLength() / sqr(maxLength);
int split = realSplit;
assert(realSplit-split >= 0.0);
Converting a floating-point value to an integer value discards the fractional part. For values greater than or equal to 0, your assert holds. For values less than 0 it goes the other way.