Re: Turn a float into a value between 0 and 1 (inclusive)?

2017-11-21 Thread Biotronic via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 09:21:29 UTC, Chirs Forest wrote: 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

Re: Turn a float into a value between 0 and 1 (inclusive)?

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 09:53:33 UTC, Petar Kirov [ZombineDev] wrote: On Tuesday, 21 November 2017 at 09:21:29 UTC, Chirs Forest wrote: 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 migh

Re: Turn a float into a value between 0 and 1 (inclusive)?

2017-11-21 Thread Petar via Digitalmars-d-learn
On Tuesday, 21 November 2017 at 09:21:29 UTC, Chirs Forest wrote: 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

Turn a float into a value between 0 and 1 (inclusive)?

2017-11-21 Thread Chirs Forest via Digitalmars-d-learn
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 d