Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #[Function List]────────────
- #fix, fixlog, disnum, changenum, calc
- #───────────────────
- function fix(inf: text, type: number) :: number:
- set {_infa::*} to split {_inf} by "e"
- set {_infa::%{_type}%} to "%{_infa::%{_type}%}%" parsed as a number
- return {_infa::%{_type}%}
- function fixlog(inf: text) :: number:
- set {_a} to fix({_inf}, 1)
- set {_b} to fix({_inf}, 2)
- return log({_a})+{_b}
- function disnum(inf: text, p: player) :: text:
- set {_a} to fix({_inf}, 1)
- set {_expo} to fix({_inf}, 2)
- set {_fixexpo} to nn({_expo}, {_p})
- return "%{_a}%e%{_fixexpo}%"
- function changenum(inf: number) :: text:
- set {_e} to floor(log({_inf}))
- set {_c} to "%{_inf}/(10^{_e})%e%{_e}%"
- return {_c}
- on load:
- set {_a} to "5e502"
- broadcast "%fix({_a}, 2)%"
- broadcast "%fixlog({_a})%"
- on load:
- broadcast "aaaaaq"
- function fixnum(inf: text) :: number:
- if {_inf} contains "e":
- set {_a} to fix({_inf}, 1)
- set {_b} to fix({_inf}, 2)
- return {_a}*10^{_b}
- else:
- set {_inf} to {_inf} parsed as a number
- return {_inf}
- function calc(num1: text, calc: text, num2: text) :: text:
- set {_mm} to -1 if {_calc} is "-" or "/"
- set {_mm} to 1 if {_calc} is "+" or "*"
- if {_calc} is "+" or "-":
- set {_n11} to fix({_num1}, 1)
- set {_n12} to fix({_num1}, 2)
- set {_n21} to fix({_num2}, 1)
- set {_n22} to fix({_num2}, 2)
- set {_expodif} to {_n12}-{_n22}
- set {_newnum} to ({_mm}*{_n21}+{_n11}*10^{_expodif})/10^floor(log({_n21}+{_n11}*10^{_expodif}))
- set {_newexpo} to {_n22}+floor(log({_n21}+{_n11}*10^{_expodif}))
- set {_text} to "%{_newnum}%e%{_newexpo}%"
- if {_mm} is 1:
- set {_text} to {_num1} if {_expodif} > 9
- set {_text} to {_num2} if {_expodif} < -9
- else:
- set {_text} to {_num1} if {_expodif} > 9
- set {_text} to "%-1*{_n21}%e%{_n22}%" if {_expodif} < -9
- if {_calc} is "*" or "/":
- set {_nl1} to fixlog({_num1})
- set {_nl2} to fixlog({_num2})
- set {_newnum} to 10^({_nl1}+{_mm}*{_nl2}-floor({_nl1}+{_mm}*{_nl2}))
- set {_newexpo} to floor({_nl1}+{_mm}*{_nl2})
- set {_text} to "%{_newnum}%e%{_newexpo}%"
- if {_calc} is "^":
- set {_nl1} to fixlog({_num1})
- set {_nl2} to fixlog({_num2})
- set {_fixnum} to fixnum({_num2})
- set {_newnum} to 10^({_nl1}*{_fixnum}-floor({_nl1}*{_fixnum}))
- set {_newexpo} to floor({_nl1}*{_fixnum})
- set {_text} to "%{_newnum}%e%{_newexpo}%"
- return {_text}
Advertisement
Add Comment
Please, Sign In to add comment