familychicken

Untitled

Feb 28th, 2022 (edited)
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. #[Function List]────────────
  2. #fix, fixlog, disnum, changenum, calc
  3. #───────────────────
  4. function fix(inf: text, type: number) :: number:
  5. set {_infa::*} to split {_inf} by "e"
  6. set {_infa::%{_type}%} to "%{_infa::%{_type}%}%" parsed as a number
  7. return {_infa::%{_type}%}
  8.  
  9. function fixlog(inf: text) :: number:
  10. set {_a} to fix({_inf}, 1)
  11. set {_b} to fix({_inf}, 2)
  12. return log({_a})+{_b}
  13.  
  14. function disnum(inf: text, p: player) :: text:
  15. set {_a} to fix({_inf}, 1)
  16. set {_expo} to fix({_inf}, 2)
  17. set {_fixexpo} to nn({_expo}, {_p})
  18. return "%{_a}%e%{_fixexpo}%"
  19.  
  20. function changenum(inf: number) :: text:
  21. set {_e} to floor(log({_inf}))
  22. set {_c} to "%{_inf}/(10^{_e})%e%{_e}%"
  23. return {_c}
  24.  
  25.  
  26. on load:
  27. set {_a} to "5e502"
  28. broadcast "%fix({_a}, 2)%"
  29. broadcast "%fixlog({_a})%"
  30.  
  31. on load:
  32. broadcast "aaaaaq"
  33.  
  34.  
  35. function fixnum(inf: text) :: number:
  36. if {_inf} contains "e":
  37. set {_a} to fix({_inf}, 1)
  38. set {_b} to fix({_inf}, 2)
  39. return {_a}*10^{_b}
  40. else:
  41. set {_inf} to {_inf} parsed as a number
  42. return {_inf}
  43.  
  44. function calc(num1: text, calc: text, num2: text) :: text:
  45. set {_mm} to -1 if {_calc} is "-" or "/"
  46. set {_mm} to 1 if {_calc} is "+" or "*"
  47. if {_calc} is "+" or "-":
  48. set {_n11} to fix({_num1}, 1)
  49. set {_n12} to fix({_num1}, 2)
  50. set {_n21} to fix({_num2}, 1)
  51. set {_n22} to fix({_num2}, 2)
  52. set {_expodif} to {_n12}-{_n22}
  53. set {_newnum} to ({_mm}*{_n21}+{_n11}*10^{_expodif})/10^floor(log({_n21}+{_n11}*10^{_expodif}))
  54. set {_newexpo} to {_n22}+floor(log({_n21}+{_n11}*10^{_expodif}))
  55. set {_text} to "%{_newnum}%e%{_newexpo}%"
  56. if {_mm} is 1:
  57. set {_text} to {_num1} if {_expodif} > 9
  58. set {_text} to {_num2} if {_expodif} < -9
  59. else:
  60. set {_text} to {_num1} if {_expodif} > 9
  61. set {_text} to "%-1*{_n21}%e%{_n22}%" if {_expodif} < -9
  62. if {_calc} is "*" or "/":
  63. set {_nl1} to fixlog({_num1})
  64. set {_nl2} to fixlog({_num2})
  65. set {_newnum} to 10^({_nl1}+{_mm}*{_nl2}-floor({_nl1}+{_mm}*{_nl2}))
  66. set {_newexpo} to floor({_nl1}+{_mm}*{_nl2})
  67. set {_text} to "%{_newnum}%e%{_newexpo}%"
  68. if {_calc} is "^":
  69. set {_nl1} to fixlog({_num1})
  70. set {_nl2} to fixlog({_num2})
  71. set {_fixnum} to fixnum({_num2})
  72. set {_newnum} to 10^({_nl1}*{_fixnum}-floor({_nl1}*{_fixnum}))
  73. set {_newexpo} to floor({_nl1}*{_fixnum})
  74. set {_text} to "%{_newnum}%e%{_newexpo}%"
  75. return {_text}
  76.  
  77.  
Advertisement
Add Comment
Please, Sign In to add comment