On Sunday, 25 February 2018 at 08:46:19 UTC, rumbu wrote:
On Sunday, 25 February 2018 at 08:08:30 UTC, psychoticRabbit wrote:


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'??


Because writeln(someFloat) is equivalent to writefln("%g", someFloat). And according to printf specification, "trailing zeros are removed from the fractional part of the result; a decimal point appears only if it is followed by at least one digit"

oh. that explains it.

I would have preffered it defaulted java style ;-)

System.out.println(1.0); // i.e. it prints 'what I told it to print'.

  • iota to array psychoticRabbit via Digitalmars-d-learn
    • Re: iota to array Jonathan M Davis via Digitalmars-d-learn
    • Re: iota to array Seb via Digitalmars-d-learn
    • Re: iota to array psychoticRabbit via Digitalmars-d-learn
      • Re: iota to array Uknown via Digitalmars-d-learn
      • Re: iota to array Jonathan M Davis via Digitalmars-d-learn
      • Re: iota to array H. S. Teoh via Digitalmars-d-learn
      • Re: iota to array psychoticRabbit via Digitalmars-d-learn
        • Re: iota to arra... rumbu via Digitalmars-d-learn
          • Re: iota to ... psychoticRabbit via Digitalmars-d-learn
            • Re: iot... Andrea Fontana via Digitalmars-d-learn
              • Re:... psychoticRabbit via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... psychoticRabbit via Digitalmars-d-learn
                • ... H. S. Teoh via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... H. S. Teoh via Digitalmars-d-learn
                • ... Jonathan M Davis via Digitalmars-d-learn
                • ... H. S. Teoh via Digitalmars-d-learn
                • ... psychoticRabbit via Digitalmars-d-learn

Reply via email to