Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ext.Math
- import
- util(Math),
- ipl.factors(factorial)
- class ExtMath()
- public static const
- syms,
- eiler
- private static init()
- syms := &digits++&ucase
- eiler := 0.5772156649015328606065120
- end
- public static to_sys(x,n)
- local r,s,i,t,res
- s := list()
- t := list()
- while x >= 1 do {
- r := x%n
- put(s,r)
- x := integer(x/n)
- }
- every i := *s to 1 by -1 do {
- put(t,syms[s[i]+1])
- }
- res:=""
- every i := 1 to *t do {
- res ||:= t[i]
- }
- return res
- end
- public static from_sys(x,n)
- local r,t,i
- r := 0
- x := reverse(x)
- every i := 1 to *x do {
- if x[i] == !syms then t := find(x[i],syms)-1
- r +:= t*(n^(i-1))
- }
- return r
- end
- public static to_sys2(x,n1,n2)
- local tmp
- tmp := from_sys(x,n1)
- return to_sys(tmp,n2)
- end
- public static root(x,y)
- return x^(1.0/y)
- end
- public static discriminant(a,b,c)
- return (b^2) - 4 * a * c
- end
- public static sgn(x)
- if x < 0 then return -1 else {
- if x = 0 then return 0 else return 1
- }
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement