Page 1 of 3
Preset array of integer changes to floats on project reload
Posted: 17 Apr 2014 13:09
by Mr Bit
Greetings,
I'm trying to use an array of 256 integers in an expression for preset storing but when the project is reloaded my stored array contains floats.
Is there any way to declare/fix data type so that this conversion does not take place?
The numbers are 32bit, when the float conversion happens the number is truncated so I cannot floor to get a result.
I think using 16 bit numbers will solve my problem but will require some reworking of my project so is a last resort.
I'm getting a feeling of deja vu from when I owned the original Lemur all those years ago. The extra horse power from the ipad and stabilized scripting is a great improvement but its a shame the data handling limits and no preset system are still a major pita.
That said it has forced me to learn some good techniques to work around these limitations which I will share as soon as this last niggle has been solved.
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 01:41
by Macciza
Hi
Had a bit of a look and there may be some oddness going on, but also some ways around it all ....
I don't think there is a way to force type - an array can be anything, defining as ints does not force it to remain as such . . .
Forcing what gets stored to it by only sending it ints is the way to go
Using the floor() function at the right spots should keep things how you need it . .
Maybe send a simplified version of the project so we can see your logic ...
MM
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 01:49
by Joe Soap
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 11:47
by Mr Bit
Thanks for your replies a simple test is to make a single pad with script storing to global expression test, then save your project and reload.
test = {536870915,47457457};
On project reload test will be
{536870880.000,47457456.000}
I'm not sure how floor will help with this as I fear data type is not stored and default on recall is float also the extra .000 is busting a limit.
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 12:59
by oldgearguy
Mr Bit wrote:Greetings,
I'm trying to use an array of 256 integers in an expression for preset storing but when the project is reloaded my stored array contains floats.
Is there any way to declare/fix data type so that this conversion does not take place?
The numbers are 32bit, when the float conversion happens the number is truncated so I cannot floor to get a result.
I think using 16 bit numbers will solve my problem but will require some reworking of my project so is a last resort.
I'm getting a feeling of deja vu from when I owned the original Lemur all those years ago. The extra horse power from the ipad and stabilized scripting is a great improvement but its a shame the data handling limits and no preset system are still a major pita.
That said it has forced me to learn some good techniques to work around these limitations which I will share as soon as this last niggle has been solved.
out of morbid curiosity, what is the largest number you can use that doesn't get truncated? I see references to 32 bit numerical precision in the manual, but I didn't see a max value mentioned anywhere. I know it is at least 8,355,711 since that is the largest RGB color value...
BTW - I've had arrays I declared end up mixed integer and float when I looked in the .jzml file. I also see switch X values stored as 1.000000 when it really can only be 0 or 1.
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 14:10
by Mr Bit
oldgearguy wrote:Mr Bit wrote:Greetings,
I'm trying to use an array of 256 integers in an expression for preset storing but when the project is reloaded my stored array contains floats.
Is there any way to declare/fix data type so that this conversion does not take place?
The numbers are 32bit, when the float conversion happens the number is truncated so I cannot floor to get a result.
I think using 16 bit numbers will solve my problem but will require some reworking of my project so is a last resort.
I'm getting a feeling of deja vu from when I owned the original Lemur all those years ago. The extra horse power from the ipad and stabilized scripting is a great improvement but its a shame the data handling limits and no preset system are still a major pita.
That said it has forced me to learn some good techniques to work around these limitations which I will share as soon as this last niggle has been solved.
out of morbid curiosity, what is the largest number you can use that doesn't get truncated? I see references to 32 bit numerical precision in the manual, but I didn't see a max value mentioned anywhere. I know it is at least 8,355,711 since that is the largest RGB color value...
BTW - I've had arrays I declared end up mixed integer and float when I looked in the .jzml file. I also see switch X values stored as 1.000000 when it really can only be 0 or 1.
It seems to work up to 24bit.If you imagine 32 switches representing our 32 bits with switch 1 and 24 on this is where its breaks,the number generated with switch 1 and 23 is stored and recalled properly(aside from being converted to a float)
Yes I've seen the mixed INT and float thing too!
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 14:20
by Macciza
Hi
floor() will convert the floating point number to the next lower int . . .
There is no 'data type not stored' or 'default recall as float' . . .
There may be a bug or two that is affecting what you are seeing . . .
Try using an onLoad script at project level with the same code . . .
So - use floor() in your scripts to set values as ints, or use floor() in the Monitor to see it as an int
Pretty sure its signed 32 bit ints so range is −2,147,483,648 to 2,147,483,647
Does go beyond this but numbers get folded/flipped
Re: Preset array of integer changes to floats on project rel
Posted: 18 Apr 2014 14:48
by Mr Bit
I've rewritten my save routine to work with 16 bit chunks, 32x32 conway's game of life is now alive!
I'm just polishing it up before I make it available.
Bit
Re: Preset array of integer changes to floats on project rel
Posted: 19 Apr 2014 17:48
by Mr Bit
Re: Preset array of integer changes to floats on project rel
Posted: 29 Apr 2014 18:35
by threeLeggedLemur
Hi,
Is there a solution to the OP problem? I am suffering the same issue. Using MrBit's example project...
test = {floor(0x02ffffff),floor(47457457)};
When executed, the monitor correctly displays {50331647, 47457457 }
However after a project save and reload we get this from the monitor;
{50331648.000, 47457456.000}
If the values are dynamically created and stored with the project rather than hard coded, can someone explain how using a floor will solve this problem? The value is being truncated at some point, either on the save project or the reload. Using onLoad doesn't help as the value is already corrupt, sure I can floor the value but that just gives me an integer containing the wrong value. At the point of project save we can clearly see the values are integers so should be stored as such.
I cant see how 'Macciza's suggestion of using floor's addresses this issue.
In effect this limits the practical max size of an integer to 24 bits. The problem is particularly nasty as it all works fine until you reload your project.
Macciza:"Pretty sure its signed 32 bit ints so range is −2,147,483,648 to 2,147,483,647, Does go beyond this but numbers get folded/flipped"
So yes internally during script execution this is the case, but practically one cant use this full range as the data is lost on a project save/load.
Any solutions to this fault?