Byte Arrays
BlitzMax Forums/BlitzMax Beginners Area/Byte Arrays
| ||
Hmm. Stumped. Why can i do this: Local test:int[] = [3,4] ....which is fine, but when I change int to byte: Local test:byte[] = [3,4] I get," unable to convert from 'int array' to 'byte array'? Confused! Thanks for help in advance. |
| ||
I came across the same problem. for int and float Arrays you can just type: Local a:int[] = [1 , 2 , 3] local b:float[] = [1.0 , 2.0 , 3.0] but for byte and double arrays you will have to do this. Local a:byte[] = [Byte(1) , Byte(2) , Byte(3)] and Local b:Double[] = [Double(1.0) , Double(2.0) , Double(3.0)] At least this is what I am doing. |
| ||
wierd.......same for shorts as well. Appreciate the info. |
| ||
I think it has to do with int being default type. Think this works: Local test:Byte[,] = new Byte[3,4] |
| ||
It's not so wierd. Thing about it like this : When you are writing in the IDE 1 Max get it as an Int. The same goes to Float if you write 1.0 Max get it as Float. Run this : Print 10 / 3 Print 10 / 3.0 Print 10.0 / 3 Print 10 / Double(3) |
| ||
If you type in a literal number, it is automatically assumed to be Integer size unless you specify otherwise. So the low numbers you're defining in your array are Integer-size data, trying to be squeezed into byte-size storage spaces, which produces this error. You just need to do Byte(Number) or Number:Byte, ie Local test:byte[] = [3:Byte,4:Byte] |
| ||
i understand why..but that's weak. |
| ||
If they were to build in automatic detection of the `type` of literal values for use in arrays, they would need the same functionality to apply across the board, which would change the way that Max on the whole assumes things to be integers. They'd either have to change it all, or none at all. |