Alfred unit converter is a smart calculator for Alfred with support for unit conversions to make it a bit comparable to the Google Calculator and Wolfram Alpha.
93
stars
15
forks
source link
Filter the denominators that can be shown for fractional units #45
This PR filters the denominators that can be shown for fractional units, showing decimals otherwise. While units like inches are commonly written as fractions, e.g., "5/8 inch", large denominators are uncommon.
For example, "57 mm to in" currently produces the response "57 millimeters = 285/127 inch", which I don't find very helpful. This PR changes the output to "57 millimeters = 2.244094 inch".
It also changes split units, for example "1357 mm to ft" outputs "1357 millimeters = 4.4521 foot" instead of:
Split units with allowed denominators still work, for example "113.125 in to ft" gives:
113.125 inch = 9.427083 foot
113.125 inch = 9 foot 41/8 inch
113.125 inch = 9 foot 5 1/8 inch
instead of:
113.125 inch = 905/96 foot
113.125 inch = 9 41/96 foot
113.125 inch = 9 foot 41/8 inch
113.125 inch = 9 foot 5 1/8 inch
And "113 in to ft" gives:
113 inch = 9.416667 foot
113 inch = 9 foot 5 inch
instead of:
113/12 foot
113 inch = 9 5/12 foot
113 inch = 9 foot 5 inch
Note that the denominator 12 is excluded as the inches split unit is more useful anyways.
An alternate solution would be to append the decimal as an additional output, but I think that would clutter the results, and denominators like 96 or 127 probably aren't useful to many people anyway.
The ALLOWED_DENOMINATORS set is just an initial thought, so I'm open to additions or removals.
This PR filters the denominators that can be shown for fractional units, showing decimals otherwise. While units like inches are commonly written as fractions, e.g., "5/8 inch", large denominators are uncommon.
For example, "57 mm to in" currently produces the response "57 millimeters = 285/127 inch", which I don't find very helpful. This PR changes the output to "57 millimeters = 2.244094 inch".
It also changes split units, for example "1357 mm to ft" outputs "1357 millimeters = 4.4521 foot" instead of:
Split units with allowed denominators still work, for example "113.125 in to ft" gives:
instead of:
And "113 in to ft" gives:
instead of:
Note that the denominator 12 is excluded as the inches split unit is more useful anyways.
An alternate solution would be to append the decimal as an additional output, but I think that would clutter the results, and denominators like 96 or 127 probably aren't useful to many people anyway.
The
ALLOWED_DENOMINATORS
set is just an initial thought, so I'm open to additions or removals.