Improve ReverseResistorColours.pm
Currently, the goodie returns 10ohm for "brown black gold silver resistor", which is wrong, as this is the code for 1ohm. * add gold and silver multipliers (x0.1 and x0.01) * simplify the multiplier formula * remove unused "mult" variablemaster
parent
1ff5c64832
commit
6f1095218f
|
@ -21,8 +21,8 @@ my %coloursToDigits = (
|
|||
'violet' => { value => 7, tolerance => .1 },
|
||||
'grey' => { value => 8, tolerance => .05 },
|
||||
'white' => { value => 9, tolerance => '' },
|
||||
'gold' => { value => '', tolerance => 5 },
|
||||
'silver' => { value => '', tolerance => 10 },
|
||||
'gold' => { value => '-1', tolerance => 5 },
|
||||
'silver' => { value => '-2', tolerance => 10 },
|
||||
);
|
||||
|
||||
handle query_raw => sub {
|
||||
|
@ -40,10 +40,7 @@ handle query_raw => sub {
|
|||
}
|
||||
$resistance += ($coloursToDigits{$colours[0]}{value} * 10);
|
||||
$resistance += $coloursToDigits{$colours[1]}{value};
|
||||
for (my $i = 0; $i < $coloursToDigits{$colours[2]}{value}; $i++) {
|
||||
$resistance = $resistance * 10;
|
||||
}
|
||||
my $mult = $coloursToDigits{$colours[2]}{value};
|
||||
$resistance = $resistance * (10 ** $coloursToDigits{$colours[2]}{value});
|
||||
if (exists $colours[3]) {
|
||||
$marginE = $coloursToDigits{$colours[3]}{tolerance};
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue