diff --git a/draw.go b/draw.go index a380f9b..e51343a 100644 --- a/draw.go +++ b/draw.go @@ -136,13 +136,32 @@ func drawNumberReadoutsFloat () { application.SetDot((25 - len(err.Error())) / 2, height - 6) fmt.Fprint(application, err.Error()) } else { - // TODO: display floats in these radixes. ignore the whole - // signs thing. floats are always signed so we need to always - // display a sign. - // drawHexadecimal (0, height - 10, uint64(number)) - // drawDecimal (0, height - 8, uint64(number)) - // drawOctal (0, height - 6, uint64(number)) - drawBinary (0, height - 4, math.Float64bits(number)) + firstHalf := int64(math.Floor(number)) + secondHalf := (number - math.Floor(number)) + + application.SetDot(0, height - 7) + fmt.Fprint(application, "10") + application.SetColor(0, height - 7, stone.ColorBlue) + 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) + } } }