calculator
I don’t like the new calculator in Windows. Mainly because it cannot be used fully with only the keyboard.
In the old calculator; doing a simple calculation with an exponent could be done with the caret character (like this: 5^2 = 25), but now this requires using an on-screen button.
I dislike the calculator so much that I removed it and started doing my calculations in the command line. To add some power and to make it simpler, I wrote a little perl script:
#!perl
use 5.030;
use strict;
use Math::Trig;
our $help = "Type expression and press enter.
Start expression with operator to apply it to the previous result.
Press Ctrl+C to exit.";
our $pi = pi();
while(1){
print "#";
chomp(my $expression = <STDIN>);
if ($expression =~ /help|\-h/g ) {
say $help;
next;
}$expression =~ s/pi/$pi/g;
if( $expression =~ /^[\*\-\+\/\%\&\|\^\~\<\>]/ ){
$expression = $_.$expression;
}$_ = eval($expression);
say;
}
^
is a bitwise operator in Perl, so to do exponents I
have to use **
.
However, There’s More Than One Way To Do It; here’s a one-liner
that’ll do the trick, and in some ways it’s even more powerful:
perl -E 'while(<STDIN>){say eval, "\n";}
This lets you type in any Perl code and evaluate the result directly in the command line. Press Ctrl+C to get out of it.
Then I discovered microsoft/PowerToys, with its Run toy which has a built in calculator that can be brough up by pressing Alt+Space. This is what I use now.