Better floating point readout
This commit is contained in:
parent
8c3ce9a937
commit
cf10dde21a
33
draw.go
33
draw.go
@ -136,13 +136,32 @@ func drawNumberReadoutsFloat () {
|
|||||||
application.SetDot((25 - len(err.Error())) / 2, height - 6)
|
application.SetDot((25 - len(err.Error())) / 2, height - 6)
|
||||||
fmt.Fprint(application, err.Error())
|
fmt.Fprint(application, err.Error())
|
||||||
} else {
|
} else {
|
||||||
// TODO: display floats in these radixes. ignore the whole
|
firstHalf := int64(math.Floor(number))
|
||||||
// signs thing. floats are always signed so we need to always
|
secondHalf := (number - math.Floor(number))
|
||||||
// display a sign.
|
|
||||||
// drawHexadecimal (0, height - 10, uint64(number))
|
application.SetDot(0, height - 7)
|
||||||
// drawDecimal (0, height - 8, uint64(number))
|
fmt.Fprint(application, "10")
|
||||||
// drawOctal (0, height - 6, uint64(number))
|
application.SetColor(0, height - 7, stone.ColorBlue)
|
||||||
drawBinary (0, height - 4, math.Float64bits(number))
|
application.SetColor(1, height - 7, stone.ColorBlue)
|
||||||
|
|
||||||
|
application.SetDot(3, height - 7)
|
||||||
|
fmt.Fprintf(application, "%+d", firstHalf)
|
||||||
|
application.SetRune(3, height - 6, '.')
|
||||||
|
|
||||||
|
for index := 4; index < 25; index ++ {
|
||||||
|
secondHalf *= 10
|
||||||
|
secondHalf = math.Mod(secondHalf, 10)
|
||||||
|
digit := rune(secondHalf) + '0'
|
||||||
|
application.SetRune(index, height - 6, digit)
|
||||||
|
}
|
||||||
|
|
||||||
|
drawBinary(0, height - 4, math.Float64bits(number))
|
||||||
|
|
||||||
|
if math.Signbit(number) {
|
||||||
|
application.SetColor(3, height - 7, stone.ColorRed)
|
||||||
|
} else {
|
||||||
|
application.SetColor(3, height - 7, stone.ColorGreen)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user