Scale a number into a defined range

/ Published in: Ruby
Save to your folder(s)

Scales a number from a given range into a specific range, as explained [in this Stack Overflow]( post.

Just call it, for example like:

0.5.scale_between(0, 1, 100, 200)

The result would be `150`.

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.