Skip to content

Instantly share code, notes, and snippets.

@danieltroger
Created August 28, 2017 13:32
Show Gist options
  • Save danieltroger/71936723389c777bd2598234c29b14af to your computer and use it in GitHub Desktop.
Save danieltroger/71936723389c777bd2598234c29b14af to your computer and use it in GitHub Desktop.
% charge of a battery where 12 is 0% and 16.8 is 100%
#!/usr/bin/env php
<?php
$x = (float) $argv[1];
echo round(($x-12)/(4.8/100),2) . "%" . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment