Hi,

Reader.readInt() will read 4 bytes binary Int data from stream.
If you want to read "123" from stdin, you need to read as String then
parse it as Int.

So, something like Int.parse(Console.IN.readLine()) should work for you.

Mikio Takeuchi
IBM Reseach - Tokyo


2012/7/23 Suhendry Effendy <suhendry.effe...@gmail.com>:
> Hi,
>
>
> How to read Int from stdin?
>
> I have this code:
>
> import x10.io.Console;
> public class Tes {
>     public static def main(args: Array[String](1)) {
>         val s = Console.IN.readInt();
>         Console.OUT.println( s );
>     }
> }
>
>
> When I give input 123 in console, I get 825373450 as the output instead of
> 123. What's happened?
> Is there any correct and easy way to input an integer (aside from reading as
> String and parse it as Int)?
>
>
> Thanks.
>
>
> Suhendry Effendy
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> X10-users mailing list
> X10-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/x10-users
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
X10-users mailing list
X10-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/x10-users

Reply via email to