literals

superdan super at dan.org
Sun Mar 28 14:02:31 PDT 2010


Don Wrote:

> so wrote:
> > Hello Don, finally!
> > 
> > It is hard to explain yourself when you don't know the people you talk 
> > have numeric coding background.
> > Since we know you have done much numeric and generic coding, it will be 
> > enough for me if you understand what i mean/ask/want,
> > and say what i am talking is ridiculous, or think that i am trolling, 
> > just say so and i shut up! :)
> 
> You're definitely not trolling! I'm not 100% sure of which issue you're 
> referring too, but I'm aware of a few, for example:

he wanna 1.0 to adapt to T. i'm sayin' if u pass float to inv 1.0 gotta be 10.F but if u pass real to in 1.0 gotta be 1.0L or shit.

really dat iz happening already I guess but therez conversion shit goin' down.

hey mr. so i think u should check a thread on octal literalz shit a week ago or so. like octal!"177" iz 0177 and octal!"177L" iz 0177L and shit.

if needed this can be done for floating shit too.

T inv(T)(T shit)
{
    return floating_literal!(T, "1.0") / shit;
}

floating_literal give u da right type. prolly therez some simple string mixin n shit.

> (1) Converting a floating point literal into a double literal is usually 
> not lossless.
> 0.5f, 0.5, and 0.5L are all exactly the same number, since they are 
> exactly representable.
> But 0.1 is not the same as 0.1L.
> So it's a bit odd that this silent lossless conversion is taking place.
> It does have a very strong precedent from C, however.

u mean lossy not lossless homez.

> (2) The interaction between implicit casting and template parameters is 
> quite poor. Eg, the fact that '0' is an int, not a floating point type, 
>   means that something simple like:
>   add(T)(T x) if (isFloatingPoint!(T))
> doesn't work properly. It is not the same as:
> add(real x)
> since it won't allow add(0).
> 
> Which is pretty annoying. Why can't 0 just mean zero???

yeah. and shit 0 its an octal constant. fuck.




More information about the Digitalmars-d mailing list