Skip to content

When I read the number by read_byte, it prints I guess ASCII number.. #3479

@ghost

Description

How can I read pure decimal?

Please Let me know it .

I attach source below.

fn main(){
    let my_number = io::stdin().read_byte() as int;
//    let mut my_number = 0;
    io::println(int::str(my_number));    

    match my_number{
        0       =>  io::println("zero"),
        1|2     =>  io::println("one or two"),
        3..10   =>  io::println("three to ten"),
        _       =>  io::println("something else")
    }   

}

OUTPUT
1
49
something else

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions