diff --git a/lib/DDG/Goodie/Conversions.pm b/lib/DDG/Goodie/Conversions.pm index 46378c807..1e8bd1294 100755 --- a/lib/DDG/Goodie/Conversions.pm +++ b/lib/DDG/Goodie/Conversions.pm @@ -153,7 +153,7 @@ handle query_lc => sub { # We only display it in exponent form if it's above a certain number. # We also want to display numbers from 0 to 1 in exponent form. - if($result->{'result'} > 1_000_000 || abs($result->{'result'}) < 1) { + if($result->{'result'} > 9_999_999 || abs($result->{'result'}) < 1) { $formatted_result = (sprintf "%.${precision}g", $result->{'result'}); } } diff --git a/t/Conversions.t b/t/Conversions.t index f3ab746cb..bb7bb584a 100755 --- a/t/Conversions.t +++ b/t/Conversions.t @@ -780,14 +780,14 @@ ddg_goodie_test( physical_quantity => 'power' }) ), - '1 gigawatt in horsepower' => test_zci( - '1 gigawatt = 1.34 * 10^6 horsepower', + '10 gigawatts in horsepower' => test_zci( + '10 gigawatts = 1.34 * 10^7 horsepower', structured_answer => make_answer({ - markup_input => '1', - raw_input => '1', - from_unit => 'gigawatt', - styled_output => '1.34 * 106', - raw_answer => '1.34*10^6', + markup_input => '10', + raw_input => '10', + from_unit => 'gigawatts', + styled_output => '1.34 * 107', + raw_answer => '1.34*10^7', to_unit => 'horsepower', physical_quantity => 'power' }) @@ -2769,13 +2769,13 @@ ddg_goodie_test( }) ), '3000 km to m' => test_zci( - '3,000 kilometers = 3 * 10^6 meters', + '3,000 kilometers = 3,000,000 meters', structured_answer => make_answer({ markup_input => '3,000', raw_input => '3000', from_unit => 'kilometers', - styled_output => '3 * 106', - raw_answer => '3*10^6', + styled_output => '3,000,000', + raw_answer => '3000000', to_unit => 'meters', physical_quantity => 'length' }) @@ -2804,6 +2804,18 @@ ddg_goodie_test( physical_quantity => 'length' }) ), + 'how many bytes in a mebibyte?' => test_zci( + '1 mebibyte = 1,048,576 bytes', + structured_answer => make_answer({ + markup_input => '1', + raw_input => '1', + from_unit => 'mebibyte', + styled_output => '1,048,576', + raw_answer => '1048576', + to_unit => 'bytes', + physical_quantity => 'digital' + }) + ), 'how many megabytes in a gigabyte?' => test_zci( '1 gigabyte = 1,000 megabytes', structured_answer => make_answer({