1
0
Fork 0

work on fixed

This commit is contained in:
coaljoe 2020-10-27 19:19:08 +03:00
parent 4dbf333ab9
commit cd3e25696d
1 changed files with 16 additions and 0 deletions

View File

@ -3,6 +3,7 @@
module fixed
import math
import strconv
const (
c_n_places = 7
@ -85,6 +86,21 @@ pub fn (f Fixed) div(b Fixed) Fixed {
return new_f(f.float() / b.float())
}
// Get value as float
pub fn (f Fixed) float() f64 {
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
}