I think it's a good idea to have things parametric and type stable. So I'd 
vote for T <: FloatingPoint.
Like this, the type you call a function with can be propagated down to all 
other functions and no conversions are needed.
As you said, this gets difficult as some people have Float64 hard coded all 
over the place. It's understandable as John pointed out. 
But for someone like me who works with GPU's which depending on the 
graphics card perform up to 30 times faster with Float32, this is quite 
annoying as I always need to convert&copy.

Am Donnerstag, 5. März 2015 17:55:40 UTC+1 schrieb Benjamin Deonovic:
>
> Moving a post from julia issues to here since it is more appropriate: 
> https://github.com/JuliaLang/julia/issues/10408
>
> If I am making a function or composite type that involves floating point 
> numbers, should I enforce those numbers to be Float64 or FloatingPoint? I 
> thought 
> it should be FloatingPoint so that the function/type will work with any 
> kind of floating point number. However, several julia packages enforce 
> Float64 (e.g. Distributions package Multinomial distribution) and so I run 
> into problems and have to put in a lot of converts in my code to Float64. Am 
> I doing this wrong? I'm quite new to julia
>
>
> I don't have any intention to use non Float64 floatingpoints numbers, I'm 
> just trying to write good code. I saw a lot of examples where people 
> recommended to to use Integer rather than Int64 or String rather than 
> ASCIIString, etc. I'm just trying to be consistent. I'm fine just using 
> Float64 if that is the appropriate approach here.
>

Reply via email to