Closed jonathanabennett closed 1 year ago
In Common Lisp, single-precision floating-point is the default, so both 0.0
and 0s0
represent single-precision floating-point numbers. To use double-precision floating-point, you need to write it as 0d0
. Therefore, your code should be modified as follows:
(let ((level-bar-widget (gtk:make-level-bar :min-value 0d0 :max-value 4d0)))
(setf (gtk:level-bar-mode level-bar-widget) gtk:+level-bar-mode-discrete+)
(setf (gtk:level-bar-value level-bar-widget) 2d0)
(gtk:box-append box level-bar-widget))
Aha, so maybe I'm doing this wrong but what if the data in the code is an integer? I'm trying to draw the HP a unit has remaining and I had thought that a discrete-mode level-bar from 0 to unit/max-hp, with the value set to unit/current-hp would be the best way to do that. But you can't lose half a hitpoint, so I'm keeping it internally as an int.
Is there another widget that would be better for this? I had originally considered making a drawing-area and drawing filled and emptied circles to mark of hits, but then I found the level bar.
I went ahead and just used either 0d0
or (float (num/accessor obj) 0d0)
and it is working. So I'll just run with that for now since looking through the widget gallery didn't give me any more inspiration.
Many functions in GTK accept double-precision floating-point numbers as parameters. You can also use (coerce 123 'double-float)
to achieve the same effect. You don't have to worry about the range of values because double-precision floating-point numbers can represent a much larger range than the commonly used int
in C or Java.
when executing the code
I receive the following error:
I receive the same error when using 0.0, 4.0, and 2.0 and my fumbling around inside the GTK and GOBJ namespaces doesn't return anything that looks like DOUBLE-FLOAT to me.