question

Craig DIckson avatar image
0 Likes"
Craig DIckson asked tannerp commented

Bundle data as integer?

I am reading a large table from Excel (several actually), and I'll be searching it, so I want to use a bundle for speed. But for some reason it reads all numeric values as double even if they're integers in the original Excel. If I query, I have to make my reference double then, even if they're integers. But if I use a table instead of bundle, they are definitely integers.

Am I missing something or is this just a charcteristic of bndles?

FlexSim 18.2.2
tablesintegerbundles
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Jordan Johnson avatar image
3 Likes"
Jordan Johnson answered Jordan Johnson commented

Excel stores values only as doubles. You can format them as integers, but when FlexSim gets the values from Excel, Excel reports them as doubles.

If you use a table instead of a bundle, it means you are storing the data on treenodes, which always store values as a double. The table view formats them as integers, but they are doubles. The treenode does not distinguish between integers and doubles.

Also, if you are searching each row, a bundle is not any faster than a treenode table. The bundle's advantage is that it takes significantly less memory. For memory purposes, if you make a bundle yourself, you can instruct the bundle to store values as integers. However, when you retrieve the value, the bundle will convert it to a double, for compatibility with the rest of FlexSim.

All that being said, in FlexScript, you can easily treat a number as an integer:

int myValue = Table("SomeTable")[3][2];
Table("SomeOtherTable")[2][1] = myValue;
double otherValue = 5.0;
if (otherValue == myValue)
    print("values are equal);
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Craig DIckson avatar image Craig DIckson commented ·

So how does that work if I am doing a query() on the table? The match is going to be an integer by definition, as it is the index for a while loop.

0 Likes 0 ·
Jordan Johnson avatar image Jordan Johnson ♦♦ Craig DIckson commented ·

When you compare an integer to a double, the integer is upgraded to a double, and then those values are compared. This is true, even inside the query command.

0 Likes 0 ·