Fraction calculation in Perl

This Perl script is able to add,subtract,divide and multiply fractional numbers:

This is the output from 1/2 and 1.25, at first add both then subtract from the result, multiply and then divide from the result:

For a better result take a look at Perl high precision.

C# Calculator

This is an old calculator program I wrote in C# :

Feel free to copy and share.

Calculator in C++

This is my calculator in C++ with in-line assembler:

Compile the code:

output:

Calculator JavaScript

This is a little example about a JavaScript Calculator, he could calculate some simple things another solution is to use eval.





JavaScript code:   HTML code:

JavaScript series resistor circuit calculator

This is a JavaScript calculator how calculate with the ohm's law the voltage, ampere and the resistance.Its only an example but feel free to copy change or reuse this script. Try it:










UG-U1 U2
UG-U2 U1
U1+U2 UG
RG-R1 R2
RG-R2 R1
R1+R2 RG
(UG*R1)/RG U1
(UG*R2)/RG U2
UG/RG IG
U1/R1 IG
U2/R2 IG
(R1*U2)/R2 U1
(R2*U1)/R1 U2
(R2*U1)/U2 R1
(R1*U2)/U1 R2
UG/IG RG
UG/RG IG
RG*IG UG
Code:

JavaScript parallel resistor circuit calculator

This is a JavaScript calculator how calculate with the ohm's law the voltage, ampere and the resistance.Its only an example but feel free to copy change or reuse this script. Try it:










RG=1/(1/R1+1/R2)
R1=-1/(1/R2-1/RG)
R2=-1/(1/R1-1/RG)
I1=(I2*R1)/R2
I2=(I1*R2)/R1
R1=(I1*R2)/I2
R2=(I2*R1)/I1
I2=(IG/(R1+R2))*R1
I1=(IG/(R1+R2))*R2
Code:

JavaScript Ohm’s law calculator

This is the Ohm's law calculator in Javascript:


Javscript: And the HTML:

Perl percent calculation

If you have an array in Perl with values and want to check what the percentages of them you could use this little function: result looks like this:   To make a table to compare all together: For the format subs look at Perl format string to the same size. result looks like this:   If you want some colours see this: And now we have the result with colours: Screenshot_percentageFor more infos about colours see at Perl Terminal Colours.   And now we use Perl Formater for Terminal and HTML to make this table:
Percent 20 8 7 5 3 2 1 0 -1
20 100.00% 40.00% 35.00% 25.00% 15.00% 10.00% 5.00% ?% -5.00%
8 250.00% 100.00% 87.50% 62.50% 37.50% 25.00% 12.50% ?% -12.50%
7 285.71% 114.29% 100.00% 71.43% 42.86% 28.57% 14.29% ?% -14.29%
5 400.00% 160.00% 140.00% 100.00% 60.00% 40.00% 20.00% ?% -20.00%
3 666.67% 266.67% 233.33% 166.67% 100.00% 66.67% 33.33% ?% -33.33%
2 1000.00% 400.00% 350.00% 250.00% 150.00% 100.00% 50.00% ?% -50.00%
1 2000.00% 800.00% 700.00% 500.00% 300.00% 200.00% 100.00% ?% -100.00%
0 ?% ?% ?% ?% ?% ?% ?% ?% ?%
-1 -2000.00% -800.00% -700.00% -500.00% -300.00% -200.00% -100.00% ?% 100.00%