Jump to content
wolph

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

Share this post


Link to post

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

Share this post


Link to post

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

Share this post


Link to post

@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

Share this post


Link to post

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.

Share this post


Link to post

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 :)

Share this post


Link to post

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

Share this post


Link to post

Just noticed that when I press return after an operation the answer is not being copied to the clipboard. Deleted and re-loaded the WF and it's still not working. Something else I need to turn on?

Share this post


Link to post

I need to convert height in feet/inches to cm/meters. Can't figure out how to do that. I'd like to type e.g. 6'1 or 6'1" but doesn't seem to work. Anyone smarter than me?

Share this post


Link to post
On 12/16/2015 at 4:54 AM, simongade said:

I need to convert height in feet/inches to cm/meters. Can't figure out how to do that. I'd like to type e.g. 6'1 or 6'1" but doesn't seem to work. Anyone smarter than me?

 

You can do that with this workflow with the simple query "units 5'7" cm" 

 

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...