work on fixed
This commit is contained in:
parent
4dbf333ab9
commit
cd3e25696d
|
@ -3,6 +3,7 @@
|
||||||
module fixed
|
module fixed
|
||||||
|
|
||||||
import math
|
import math
|
||||||
|
import strconv
|
||||||
|
|
||||||
const (
|
const (
|
||||||
c_n_places = 7
|
c_n_places = 7
|
||||||
|
@ -85,6 +86,21 @@ pub fn (f Fixed) div(b Fixed) Fixed {
|
||||||
return new_f(f.float() / b.float())
|
return new_f(f.float() / b.float())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get value as float
|
||||||
pub fn (f Fixed) float() f64 {
|
pub fn (f Fixed) float() f64 {
|
||||||
return f64(f.fp) / f64(c_scale)
|
return f64(f.fp) / f64(c_scale)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX not tested
|
||||||
|
pub fn (f Fixed) value() f64 {
|
||||||
|
return f.float()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn (f Fixed) str() string {
|
||||||
|
// XXX fixme, temporary
|
||||||
|
|
||||||
|
v := f.float()
|
||||||
|
s := strconv.v_sprintf("%f", v)
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
Loading…
Reference in New Issue