digitalmars.D.learn - Unexpected result with std.conv.to
- Joel (4/4) Nov 14 2019 I made a feature that converts, say, [9:59am] -> [10:00am] to 1
- Jon Degenhardt (4/8) Nov 14 2019 Use a string or char[] array. e.g. writeln("9".to!int) => 9.
- Joel (2/11) Nov 14 2019 Thanks, Jon Degenhardt. I did work it out.
I made a feature that converts, say, [9:59am] -> [10:00am] to 1 minute. but found '9'.to!int = 57 (not 9). Doesn't seem right... I'm guessing that's standard though, same with ldc.
Nov 14 2019
On Friday, 15 November 2019 at 03:51:04 UTC, Joel wrote:I made a feature that converts, say, [9:59am] -> [10:00am] to 1 minute. but found '9'.to!int = 57 (not 9). Doesn't seem right... I'm guessing that's standard though, same with ldc.Use a string or char[] array. e.g. writeln("9".to!int) => 9. With a single 'char' what is being produced is the ascii value of the character.
Nov 14 2019
On Friday, 15 November 2019 at 04:26:58 UTC, Jon Degenhardt wrote:On Friday, 15 November 2019 at 03:51:04 UTC, Joel wrote:Thanks, Jon Degenhardt. I did work it out.I made a feature that converts, say, [9:59am] -> [10:00am] to 1 minute. but found '9'.to!int = 57 (not 9). Doesn't seem right... I'm guessing that's standard though, same with ldc.Use a string or char[] array. e.g. writeln("9".to!int) => 9. With a single 'char' what is being produced is the ascii value of the character.
Nov 14 2019