Oxygen Basic
Programming => Problems & Solutions => Topic started by: Brian Alvarez on December 13, 2018, 12:58:11 PM
-
Hello, i am storing values to a variable as follows:
macro _sm_m_set(vu, of, dt, nv, ln a, b, c)
sys a = @vu + of
dt c = nv
int b = sizeof(c)
if ln then b = ln
copy a, @c, b
end macro
Basically i take the address of the UDT with @vu, then i look for the member offset with + of, then i create a variable c of the UDT member data type, in this case DOUBLE, and store the new value nv on it. the lb is, in case the data is a static string, to write no more than the allowed bytes, then i copy the variable c at the address of the UDT member b number of bytes.
It works but, is there a way to add a little more accuracy?
-
I'm uclear. Are you storing floats in string form? Would it be preferable to store them in their native binary?
-
They are stored in binary. UDT strings are also stored in binary (no bstr's).
By the way, all of a sudden they started behaving better. I improved the code like this:
macro _sm_m_set(vu, of, dt, nv, ln a, b, c)
dt c = nv
copy @vu + of, @c, ln
end macro
The floating point elements now display:
123.411
121.09
PowerBASIC is still slightly faster. There is room for improvement. :)