Sign in to follow this  
Followers 0
z0mgItsJohn

Fractions.. Decimals.. And Percents

2 posts in this topic

;) It Wrote It Cause I Was Bored? ;)

Script : _Math.Au3

Func _Decimal_To_Percent ($Decimal)
Local $Return
$Return = ($Decimal * '100')
Return $Return
EndFunc

Func _Decimal_To_Fraction ($Decimal)
Local $Return
$Return = (_Decimal_To_Percent ($Decimal) & '/100')
Return $Return
EndFunc

Func _Fraction_To_Decimal ($Fraction)
Local $Return, $String_Split
$String_Split = StringSplit ($Fraction, '/')
$Return = ($String_Split['1'] / $String_Split['2'])
Return Round ($Return, '3')
EndFunc

Func _Fraction_To_Percent ($Fraction)
Local $Return
$Return = (_Decimal_To_Percent (_Fraction_To_Decimal ($Fraction)))
Return $Return
EndFunc

Func _Percent_To_Fraction ($Percent)
Local $Return
$Return = ($Percent & '/100')
Return $Return
EndFunc

Func _Percent_To_Decimal ($Percent)
Local $Return
$Return = (_Fraction_To_Decimal (_Percent_To_Fraction ($Percent))) 
Return $Return
EndFunc

~ Enjoy ~

Please Feel Free To Leave Comments, Bugs.., Etc...

- John :D


Latest Projects :- New & Improved TCP Chat

Share this post


Link to post
Share on other sites

Why do you use strings for numbers? :D

$Return = ($Percent & '/100')
...
..
$Fraction = GUICtrlCreateInput ('','5','5','110','23','1')

.. and could you explain the purpose (particularly the example) a little more.

Sorry, I'm not much of a mathematician ;)


Don't bother, It's inside your monitor!------GUISetOnEvent should behave more like HotKeySet()

Share this post


Link to post
Share on other sites

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
Sign in to follow this  
Followers 0