Also, if I wanted out of bounds values to wrap (2.5 becomes 0.5) how would I get that value and also have 1.0 not give me 0.0?
Turn a float into a value between 0 and 1 (inclusive)?
Chirs Forest via Digitalmars-d-learn Tue, 21 Nov 2017 01:27:51 -0800
I'm interpolating some values and I need to make an
(elapsed_time/duration) value a float between 0 and 1 (inclusive
of 0 and 1). The elapsed_time might be more than the duration,
and in some cases might be 0 or less. What's the most efficient
way to cap out of bounds values to 0 and 1? I can do a check and
cap them manually, but if I'm doing a lot of these operations I'd
like to pick the least resource intensive way.
- Turn a float into a value between 0 a... Chirs Forest via Digitalmars-d-learn
- Re: Turn a float into a value be... Petar via Digitalmars-d-learn
- Re: Turn a float into a valu... Petar via Digitalmars-d-learn
- Re: Turn a float into a value be... Biotronic via Digitalmars-d-learn