Manual table initialisation: read values divided by two ?!


#1

I'd like to manually initialise a table like this (for now):

Object: table/alloc 8b
Size: 8

Init code:
array[0] = 1;
array[1] = 4;
array[2] = 8;
array[3] = 16;
array[4] = 32;
array[5] = 64;
array[6] = 64;
array[7] = 64;

I was under the impression that I could read those values 1, 4, 8, 16, 32, 64 using a table/read object and feeding it integers from 0-7. Instead I somehow get values divided by two from the table/read object, so 0.5, 2, 4, 8, 16, 32.

I'm sure I'm doing something really basic wrong here, but I can't figure it out :sweat:

Here's a screenshot:


#2

yeah, this is a bit of a 'quirk' (rather than a bug)

it boils down to a float (blue), is bipolar and has a range of -64 to +64,
(consider if like voltage, i really wish axoloti had chose -1 to 1 ! )

int 8b, is signed and goes -127 to +127
so +127 = full range

so 127 int = 64 float, so 64 int = 32 float, 1 int = 0.5 int

the way i like to think of floats is as percentages where 64 = 100% of range...otherwise, this things do tend to catch me out :wink:

i.e try not to view floats as values ....

not sure about the disp/i..... i think the issue perhaps is, the implicit conversion, just converts the float value to int, i.e. 0.5, and then rounds it.
this is interesting, as its a bit counter to the way tables use the range to convert from int to float.
( usually disp are only debug functions, but if its in the implicit conversion, i can see where this might lead to confusions)

@johannes , is the issue that disp/i (or implicit conversion) doesn't know the range of the int, as could 8 , 16 or 32bit, so its impossible for it to do this...


Load floats into table(SDRAM) from file with constant multiplier
#3

Thank you very much :slight_smile: I've used tables a bunch in the past with table/write, but never initialised them manually before. Table/write has always worked nicely, so I assume it works basically the other way around as table/read and while the values in the table are "converted", they remain intact on the table/read output.