Greetings,
DISCLAIMER: I haven't used StreamTokenizer
yet.
I
can't see anything in the StreamTokenizer API to specifically address your
inquiry. The API seems a bit trivial - but I'm sure the
implementation is not trivial. It seems that all you know is that the
value was numeric and it's exposed as a double.
Perhaps you can use some simple casting and comparison
as in...
if( st.nval == ((long)st.nval) ) //
it's an integral value ... no fractional part
...
which should cast the double to a long (explicit cast), truncating the
fractional part, and then cast it back to double (implicit cast) for
comparison for equality with the original double value. If the original
double value has a fractional part then the comparison should
fail.
Louis W. Lembcke,
Principal
Chicago Systems Group
180 N. Stetson, Suite
3200
Chicago, IL 60601 USA
Main Tele: +1
312.444.2760
Facsimile: +1
425.969.6391
-----Original Message-----
From: Saler, Jeff [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 09, 2002 12:08 PM
To: JDJList
Subject: [jdjlist] StreamTokenizer
From: Saler, Jeff [mailto:[EMAIL PROTECTED]]
Sent: Thursday, May 09, 2002 12:08 PM
To: JDJList
Subject: [jdjlist] StreamTokenizer
Does anyone have an idea as to how to tell whether a
number read using a
StreamTokenizer
(st.nval) is an integer or a floating-point number?
http://www.sys-con.com/java/list.cfm To change your membership options, refer to:
http://www.sys-con.com/java/list.cfm
