iota to array
psychoticRabbit
meagain at meagain.com
Sun Feb 25 08:08:30 UTC 2018
On Sunday, 25 February 2018 at 06:35:07 UTC, Jonathan M Davis
wrote:
>
> It's not printing ints. It's printing doubles. It's just that
> all of the doubles have nothing to the right of the decimal
> point, so they don't get printed with a decimal point. If you
> did something like start with 1.1, then you'd see decimal
> points, because there would be data to the right of the decimal
> point. The same thing happens if you do
>
> writeln(1.0);
>
> as opposed to something like
>
> writeln(1.3);
>
thanks.
But umm.... what happended to the principle of least astonishment?
writeln(1.1); (prints 1.1)
whereas..
writeln(1.0); (prints 1)
I don't get it. Cause it's 'nicer'??
I ended up having to work around this..like this:
-------
void printArray(T)(const ref T[] a) if (isArray!(T[]))
{
if( isFloatingPoint!T)
foreach(t; a) writefln("%.1f", t);
else
foreach(t; a) writefln("%s", t);
}
-------
More information about the Digitalmars-d-learn
mailing list