Map range: Difference between revisions

no edit summary
No edit summary
No edit summary
Line 1,392:
9 -0.1
10 +0.0
</pre>
 
 
=={{header|Go}}==
<lang futurebasic>
include "NSLog.incl"
 
local fn MapRange( s as double, a1 as double, a2 as double, b1 as double, b2 as double ) as double
end fn = b1+(s-a1)*(b2-b1)/(a2-a1)
 
NSInteger i
 
for i = 0 to 10
NSLog( @"%2d maps to %5.1f", i, fn MapRange( i, 0, 10, -1, 0 ) )
next
 
HandleEvents
</lang>
Output:
<pre>
0 maps to -1.0
1 maps to -0.9
2 maps to -0.8
3 maps to -0.7
4 maps to -0.6
5 maps to -0.5
6 maps to -0.4
7 maps to -0.3
8 maps to -0.2
9 maps to -0.1
10 maps to 0.0
</pre>
 
715

edits