Data update
This commit is contained in:
parent
72eb4943cb
commit
4d5544505c
2347 changed files with 62432 additions and 16731 deletions
15
Task/Map-range/PHP/map-range.php
Normal file
15
Task/Map-range/PHP/map-range.php
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
// Map range
|
||||
|
||||
function map_range($s, $a1, $a2, $b1, $b2) {
|
||||
return ($s - $a1) * ($b2 - $b1) / ($a2 - $a1) + $b1;
|
||||
}
|
||||
|
||||
for ($i = 0; $i <= 10; $i++) {
|
||||
$mr = map_range($i, 0, 10, -1, 0); // To avoid too long line.
|
||||
echo(str_pad($i, 2, ' ', STR_PAD_LEFT)
|
||||
.' maps to: '
|
||||
.str_pad(number_format($mr, 1, '.', ''), 4, ' ', STR_PAD_LEFT)
|
||||
.PHP_EOL);
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue