2021-01-13 12:28:26 -05:00
|
|
|
package vexriscv.ip.fpu
|
|
|
|
|
|
|
|
object MiaouDiv extends App{
|
|
|
|
val input = 2.5
|
|
|
|
var output = 1/(input*0.95)
|
|
|
|
|
|
|
|
def y = output
|
|
|
|
def x = input
|
|
|
|
|
|
|
|
for(i <- 0 until 10) {
|
|
|
|
output = 2 * y - x * y * y
|
|
|
|
println(output)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//output = x*output
|
|
|
|
println(1/input)
|
|
|
|
}
|
|
|
|
|
|
|
|
object MiaouSqrt extends App{
|
|
|
|
val input = 2.0
|
|
|
|
var output = 1/Math.sqrt(input*0.95)
|
|
|
|
// def x = output
|
|
|
|
// def y = input
|
|
|
|
|
|
|
|
def y = output
|
|
|
|
def x = input
|
|
|
|
|
|
|
|
for(i <- 0 until 10) {
|
2021-01-14 09:56:56 -05:00
|
|
|
output = y * (1.5 - x * y * y / 2)
|
2021-01-13 12:28:26 -05:00
|
|
|
println(output)
|
|
|
|
}
|
|
|
|
|
|
|
|
output = x*output
|
|
|
|
println(output)
|
|
|
|
println(s"ref ${Math.sqrt(input)}")
|
|
|
|
}
|