17 lines
359 B
Plaintext
17 lines
359 B
Plaintext
/* map s from [a, b] to [c, d] */
|
|
define m(a, b, c, d, s) {
|
|
return (c + (s - a) * (d - c) / (b - a))
|
|
}
|
|
|
|
scale = 6 /* division to 6 decimal places */
|
|
"[0, 10] => [-1, 0]
|
|
"
|
|
for (i = 0; i <= 10; i += 2) {
|
|
/*
|
|
* If your bc(1) has a print statement, you can try
|
|
* print i, " => ", m(0, 10, -1, 0, i), "\n"
|
|
*/
|
|
i; " => "; m(0, 10, -1, 0, i)
|
|
}
|
|
quit
|