Note that there is BigFloat that is also a subtype of FloatingPoint. Users 
might also define their own FloatingPoint subtype implementation that does 
not provide the appropriate convert methods, but there is nothing you can 
do to prevent the NoMethodError that will result (apart from implementing 
the correct methods).

Ivar

kl. 11:37:03 UTC+2 torsdag 3. april 2014 skrev Cristóvão Duarte Sousa 
følgende:
>
> I think the julian way is
>
> y = convert(Tv, x)
>
> On Thursday, April 3, 2014 10:11:20 AM UTC+1, Sergey Bartunov wrote:
>>
>> Given the type Tv <: FloatingPoint how can I automatically convert 
>> variable x::FloatingPoint to Tv? 
>>
>> For me the most intuitive way is to write Tv(x), but this doesn't 
>> work. Currently I perform the check: 
>>
>> y = Tv == Float32 ? float32(x) : float64(x) 
>>
>> but are there any options? In general case I may not now that the 
>> parent type (FloatingPoint in this case) has only two implementations 
>> and that they have particular converting functions like float32 or 
>> float64. 
>>
>

Reply via email to