Can't convert Float to Double in array

BlitzMax Forums/BlitzMax Programming/Can't convert Float to Double in array

Grey Alien(Posted 2007) [#1]
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.


Shambler(Posted 2007) [#2]
Looks like a bug, simplest way around it is to stick a '!' after each number like you say.


Grey Alien(Posted 2007) [#3]
yeah did that. Thanks. I guess rather than a bug it's more of an optimisation that's not been made yet.


ImaginaryHuman(Posted 2007) [#4]
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.


Grey Alien(Posted 2007) [#5]
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.


DJWoodgate(Posted 2007) [#6]
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.


Grey Alien(Posted 2007) [#7]
yeah like it hasn't been coded ;-)