Can't convert Float to Double in array
BlitzMax Forums/BlitzMax Programming/Can't convert Float to Double in array
| ||
This won't compile@Global MultiplierArray:Double[] = [0.0,0.0,0.0,0.0,0.0,0.0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.0,1.2,1.4,1.6,1.8,2.0,2.3,2.6,3.0] It gives "Compile Error: Unable to convert from 'Float Array' to 'Double Array'" Gotta say that's a bit disappointing as I'll have to typecast each float as a double. |
| ||
Looks like a bug, simplest way around it is to stick a '!' after each number like you say. |
| ||
yeah did that. Thanks. I guess rather than a bug it's more of an optimisation that's not been made yet. |
| ||
All of your numbers that you are defining for your array, e.g. 0.1,0.2,0.3,0.4,0.5,0.6,0.7 etc, are FLOATS. If you do not explicity put :Double behind each one, they will be considered FLOAT CONSTANTS. That's why it's saying it doesn't match up. You have to specify in the format that the array is in. |
| ||
AngelDaniel: Yeah thanks I put ! after them all but I'm saying that Blitz ought to know that a float can be read into a double. |
| ||
It does seem strange with all the other implicit casting going on that it does not apply to array definitions. Probably some good reason for it though. |
| ||
yeah like it hasn't been coded ;-) |