Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Adding Fractions

Aug
1,917
68
Here is a script to add fractions together.

Code:
:: Load the plugin
:: Available from http://sites.google.com/site/jlcprogrammingstuff/home/tcc/jlcutils-plugin
@if not plugin jlcutils plugin /l jlcutils
::
:: Create environment variables for the fractions
::
@setlocal
@set frac1=5/8
@set frac2=1/2
::
:: You need to determine the denominator for the fraction result.
:: I just multiply the denominators of the two fractions to get this.
::
@set denom=16
::
:: Do it
::
@echo Add %frac1 with %frac2
@echo.
@echo %frac1 = %@formatn[4.4,%@frac2real[%frac1]]
@echo %frac2 = %@formatn[4.4,%@frac2real[%frac2]]
@echo ------------
@set total=%@eval[%@frac2real[%frac1]+%@frac2real[%frac2]]
@echos %@real2frac[%total,%denom]
@echo` ` = %@formatn[4.4,%total]
@endlocal
::
:: Unload the plugin
::
@if plugin jlcutils plugin /u jlcutils
Joe
 
Back
Top