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. >
