String to Integer?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

String to Integer?

Machisuji
Seriously, I'm asking you how to get an Integer from a String.
I've tried Integer#readFrom: which does not work, probably because it expects a Stream.

After browsing through Integer and String I still have no idea how to convert a String into an Integer.
Help?


Regards,

Markus Kahl

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: String to Integer?

James Robertson-7
'300017' asNumber



James Robertson
Cincom Smalltalk Product Evangelist
http://www.cincomsmalltalk.com/blog/blogView
Talk Small and Carry a Big Class Library




On Feb 3, 2010, at 12:08 PM, Markus Kahl wrote:

> Seriously, I'm asking you how to get an Integer from a String.
> I've tried Integer#readFrom: which does not work, probably because it expects a Stream.
>
> After browsing through Integer and String I still have no idea how to convert a String into an Integer.
> Help?
>
>
> Regards,
>
> Markus Kahl
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: String to Integer?

Steven Kelly
In reply to this post by Machisuji
Or to make sure you only read the string to the first non-Integer
character:
   Integer readFrom: '300017.9' readStream
=> 300017

Or that you end up with an Integer:
   '300017.9' asNumber rounded
=> 300018

Steve

> '300017' asNumber
>
>
>
> James Robertson
> Cincom Smalltalk Product Evangelist
> http://www.cincomsmalltalk.com/blog/blogView
> Talk Small and Carry a Big Class Library
>
>
>
>
> On Feb 3, 2010, at 12:08 PM, Markus Kahl wrote:
>
> > Seriously, I'm asking you how to get an Integer from a String.
> > I've tried Integer#readFrom: which does not work, probably because
it
> expects a Stream.
> >
> > After browsing through Integer and String I still have no idea how
to

> convert a String into an Integer.
> > Help?
> >
> >
> > Regards,
> >
> > Markus Kahl
> > _______________________________________________
> > vwnc mailing list
> > [hidden email]
> > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
>
>
> _______________________________________________
> vwnc mailing list
> [hidden email]
> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: String to Integer?

Georg Heeg
In reply to this post by Machisuji

Use Integer readFromString: ‘1234‘

 

Georg

 

Georg Heeg eK, Dortmund und Köthen, HR Dortmund A 12812

Tel. +49-3496-214328, Fax +49-3496-214712

Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Markus Kahl
Gesendet: Mittwoch, 3. Februar 2010 18:08
An: vwnc
Betreff: [vwnc] String to Integer?

 

Seriously, I'm asking you how to get an Integer from a String.

I've tried Integer#readFrom: which does not work, probably because it expects a Stream.

 

After browsing through Integer and String I still have no idea how to convert a String into an Integer.

Help?

 

 

Regards,

 

Markus Kahl


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: String to Integer?

Dave Stevenson-3
In reply to this post by Machisuji
> After browsing through Integer and String ...
 
Since much behavior is inherited, it is often useful to include some superclasses in your browsing. I often right-click in the method pane of the browser and select a superclass in the 'Visibility' submenu. For example, when brosing Integer, choosing 'Visibility' -> Object would have shown me the #readFromString: class method. While browsing String, 'Visibility' -> CharacterArray would have sufficed to find the instance method #asNumber.
 
Dave Stevenson
[hidden email]



From: Markus Kahl <[hidden email]>
To: vwnc <[hidden email]>
Sent: Wed, February 3, 2010 11:08:19 AM
Subject: [vwnc] String to Integer?

Seriously, I'm asking you how to get an Integer from a String.
I've tried Integer#readFrom: which does not work, probably because it expects a Stream.

After browsing through Integer and String I still have no idea how to convert a String into an Integer.
Help?


Regards,

Markus Kahl

_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: String to Integer?

Machisuji
Thanks to all of you!

2010/2/3 Dave Stevenson <[hidden email]>
> After browsing through Integer and String ...
 
Since much behavior is inherited, it is often useful to include some superclasses in your browsing. I often right-click in the method pane of the browser and select a superclass in the 'Visibility' submenu. For example, when brosing Integer, choosing 'Visibility' -> Object would have shown me the #readFromString: class method. While browsing String, 'Visibility' -> CharacterArray would have sufficed to find the instance method #asNumber.
 
Dave Stevenson
[hidden email]



From: Markus Kahl <machisuji.ml@googlemail.com>
To: vwnc <[hidden email]>
Sent: Wed, February 3, 2010 11:08:19 AM
Subject: [vwnc] String to Integer?

Seriously, I'm asking you how to get an Integer from a String.
I've tried Integer#readFrom: which does not work, probably because it expects a Stream.

After browsing through Integer and String I still have no idea how to convert a String into an Integer.
Help?


Regards,

Markus Kahl


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc