Jump to content

Advanced calculator with fast off-line unit converter


Recommended Posts

Alfred unit converter is a really fast smart calculator for Alfred with support for unit conversions to make it a bit comparable to the Google Calculator and Wolfram Alpha.

If new units and/or other names for units should be added please let me know by creating an issue at:https://github.com/WoLpH/alfred-converter/issues

Example queries

 

Downloadable from Packal: http://www.packal.org/workflow/unit-converter

1m in cm # Just a simple conversion
2^30 byte # Using powers before conversion
5' # Converting units with special characters
20" # Like above
5 * cos(pi + 2) # Executing mathematical functions
5 * pi + 2 mm in m # Mathematical constants with unit conversion
1 * cos(pi/2) - sin(pi^2) # More advanced mathematical expressions
ln(e^10) # Testing the ln(x) alias of log _e(x)
log(e^10) # The normal log method
5+3^2" in mm # Testing math with unit conversion
1 + 2 / 3 * 4) mm^2 in cm^2 # Unbalanced paranthesis with unit conversion
((1 + 2 / 3 * 4) mm^2 in cm^2 # Unbalanced paranthesis the other way
inf - inf # Not actually possible, but we backtrack to "inf"
The list of units and conversions was downloaded from:http://w3.energistics.org/uom/poscUnits22.xml

It returns results within 50 milliseconds making it fast enough to use the results instead of the standard alfred calculator. It supports more too :)

 

Note: the parser automatically works when you start with a number or a ".". For all other cases (functions for example) it's best to just use "=". For example: "=ln(e^5)"

 

bytes.png exponent_rounding.png mathematical_functions.png square_metres.png

Edited by wolph
Link to comment

Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). 

 

I really like the multiple ways to input (0 to 9, =, .) but then it lacks full blown calculator function (ln, tan, e, cos... then don't seem to work, and they can't be the first thing in because they don't start a query).

 

Also the precision is weird 4^.5 outputs 2.0000000000000000000000000000

Link to comment

The output can be improved indeed, for me it's a bit more convenient since it just converts it to any alternative measurement instead of just from a single one to another. Not really sure what the best solution for the output should be, right now all calculations are done with a precision of 28 places which is the default for the Decimal library. I could easily increase or decrease it upon demand. Perhaps I'll even make it configurable.

 

I'll see if I can make the output slightly less messy by rounding things like 4^.5 :)

 

As for functions, there's actually a workaround for mathematical functions, try this for example: "=sin(pi/2)-cos(2pi)"

 

 mathematical_functions.png

 

 

Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). 

 

I really like the multiple ways to input (0 to 9, =, .) but then it lacks full blown calculator function (ln, tan, e, cos... then don't seem to work, and they can't be the first thing in because they don't start a query).

 

Also the precision is weird 4^.5 outputs 2.0000000000000000000000000000

Edited by wolph
Link to comment

@Florian you never know when you will need to convert square meters to miles with 19 digits of accuracy.

 

Yeah... it's nice to have accuracy but sometimes it's a bit much ;)

Right now it rounds to 6 decimal places so things like 4^.5 work without a problem but it doesn't lose precision for calculations like: (25/4)^.5

Link to comment

Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster).

 

Can't say I saw the units library before I started writing this, that's indeed a lot better. I was previously trying to use the units library from Jason Cheatham which never worked the way I liked.

 

The one thing I don't like about the units library is that it requires an internet connection, otherwise it just fails. By doing everything locally it always (on my system at least) return within 50ms making it fast enough for instant results.

 

Either way, I think I've fixed all issues (although it's not as pretty as the units library). Perhaps I can merge some things with the units library, can't find any license information though.

Link to comment
  • 2 weeks later...

Very cool concept. The outputs feel a little messy, to me units is still superior (even though i'd really like it to be faster). 

 

I really like the multiple ways to input (0 to 9, =, .) but then it lacks full blown calculator function (ln, tan, e, cos... then don't seem to work, and they can't be the first thing in because they don't start a query).

 

Also the precision is weird 4^.5 outputs 2.0000000000000000000000000000

 

If you're willing to try again. I've included some icons in the output to make everything a bit clearer. Perhaps that helps :)

Link to comment
  • 2 months later...

Loving this workflow!

 

In my daily work I add a lot of prices, sometimes 10+ numbers together. I see that if you leave a space between numbers it will multiply them together

 

(wouldn't let me embed image)

http://r.roccit.com/1539j

 

Is it possible to edit the script somewhere to make the default operation in this case be addition? 

Here's to saving my pinky finger :)

-roccit

Link to comment
  • 9 months later...
  • 11 months later...
  • 3 years later...

Hello,

 

Really amazing workflow!

Just one question how to count percentages?

I want to count these functions, examples:

 

Calculate a percentage of a number:

15% of 80

 

Calculate a percentage of a quantity:

7.5% of $12.95

 

Increase a quantity by a percentage:

$2400 + 15%

 

Compute a discounted price:

15% off of $29.95

 

Link to comment
15 minutes ago, wolph said:

Percentages were already somewhat supported but not in the way you're currently using them. Currently they're only part of ratios (i.e. parts per million)

 

I've created a new version that supports pretty much all of this but it ignores the $ sign since there's no currency support yet.

image.png.aabb65e68cceeabb5eecffdc5448415d.png

image.png.37d8a12eab5eeae30c1ce335c849faab.png

image.png.b4e7591dfd182e7ae05ff4aae9fbc95a.png

 

Wow that was as quick as could possible be. Works perfectly just tested! Thank you so much.

And I am sorry for not telling this at the beginning but few more percentage features would be nice:

Examples:

 

15 is what percent of 130?

 

What is the percentage increase/decrease? From 98 to 60

Link to comment
  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...