Perseverance is best when informed.
Tom Gibbins wrote:Weirdly enough, if I add two spaces instead of one, i get a proper output. But not with one, that returns the weird symbols in the post above. I can't understand what is going on. I tried the same code on my laptop (also Eclipse), and it produces the same results.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
That is 200 digits, what is going on here?
Perseverance is best when informed.
Perseverance is best when informed.
Winston Gutkowski wrote:
Tom Gibbins wrote:Weirdly enough, if I add two spaces instead of one, i get a proper output. But not with one, that returns the weird symbols in the post above. I can't understand what is going on. I tried the same code on my laptop (also Eclipse), and it produces the same results.
Have you tried printing out the the space without the number? That might point you in the right direction...
Winston
Stephan van Hulst wrote:The only thing I can think of is that your text editor interprets your text file using the a different character encoding than the one your application uses to write the file. Try setting the encoding on the print writer explicitly, and tell your text editor to interpret the text file using the same encoding. In this case, ASCII should be fine.
L Foster wrote:All,
I also was just reminded of something that could easily pass under one's radar. I ran @Tim's code, which is calling "Random", and the string of digits I got looked identical to what he did, at a different time of day, on different hardware, possibly a different time zone... I even re-ran it again, and got the same results.
This is reinforcing that we mustn't take Random for granted. We need to pay attention to the seeds. Same seed of '10' gives predictable results, which is not what you want when using Random for anything other than making a lot of digits.
L Foster wrote:
That is 200 digits, what is going on here?
@Tim, for this specific question, please refer to my earlier post. A single-quoted space is interpreted as char, rather than String. In that case, it is simply adding your int constant to the value 0x20, and giving you larger numbers.
For the other part, I like the suggestion given, about the encoding (by @Stephan van Hulst). Another thing you can do, is to use "octal dump", or "od", to look at the contents of your Java source file, to see exactly what is being placed into those double quotes.
a wee bit from the empire
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|