long to float variables
Fork of reScale by
reScale.cpp@1:ebb951147122, 2014-03-03 (annotated)
- Committer:
- c0ax
- Date:
- Mon Mar 03 19:57:45 2014 +0000
- Revision:
- 1:ebb951147122
- Parent:
- 0:04d95412bcd3
- Child:
- 2:1715e312322b
Changed description. Usage example is now on library homepahe
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
c0ax | 0:04d95412bcd3 | 1 | #include "reScale.h" |
c0ax | 0:04d95412bcd3 | 2 | |
c0ax | 0:04d95412bcd3 | 3 | reScale::reScale(long in_min, long in_max, long out_min, long out_max) : |
c0ax | 0:04d95412bcd3 | 4 | _inMin (in_min),_inMax(in_max),_outMin (out_min),_outMax (out_max) |
c0ax | 0:04d95412bcd3 | 5 | { |
c0ax | 0:04d95412bcd3 | 6 | |
c0ax | 0:04d95412bcd3 | 7 | } |
c0ax | 1:ebb951147122 | 8 | |
c0ax | 0:04d95412bcd3 | 9 | long reScale::from(long value) |
c0ax | 0:04d95412bcd3 | 10 | { |
c0ax | 0:04d95412bcd3 | 11 | return (value - _inMin) * (_outMax - _outMin) / (_inMax - _inMin) + _outMin; |
c0ax | 0:04d95412bcd3 | 12 | } |