![]() |
|
#1
|
|||
|
|||
How to read scientific number from file using javaHi
I'm not very good in programming, but currently I have a task of doing a set of programming in both java and C++ for handling VRML files as input. Currently I'm having one problem (actually I have lots of problem, but that got to do with the algorithms *groan*), which is to read a scientific number (for example: -1.26759e-006). In my program, when I know I need to read a number, I would read the string read from file as 'float'. But then I came across an input file where some of the numbers are scientific numbers, and my program returns an error. I don't know how to recognize a scientific number (when the program 'sees' one) and how to handle it.. I need help m(_ _)m Thank you for your advice..I'd really appreciate it |
|
#2
|
|||
|
|||
Re: How to read scientific number from file using javaI don't think there is a standard Java method to read scientific notation numbers.
But you may always parse it yourself with some simple code using StringTokenizer. If you want you may write a finite state machine for the parsing (a lot nicer) but I guess that for your simple needs StringTokenizer + some Double.parseDouble is ok. Shouldn't take more than 1/2 hour to finish the method. |
|
#3
|
|||
|
|||
Re: How to read scientific number from file using javaIf using StringTokenizer, then I need to separate the 2 parts in the scientific number using 'e' as deliminator. Is this what you meant?
I'm still confused as to how to handle the numbers, though...but I will try it out |
|
#4
|
|||
|
|||
Re: How to read scientific number from file using javaWell, you just read the 2 numbers with Double.parseDouble().
So you have Number1 e Number2 And you just do something like JAVA Code:
|
|
#5
|
|||
|
|||
Re: How to read scientific number from file using javaI see I see....thank you so much for the help
|
Recent GIDBlog
Welcome to Baghdad by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| How to read scientific number from file? | clara | C Programming Language | 7 | 11-Oct-2005 02:24 |
| Made program in Java, trying C++ now, file i/o problems | technickel | C++ Forum | 4 | 19-Feb-2005 00:32 |
| Yet another CD burner problem: Lite-On LSC-24082K | Erwin | Computer Hardware Forum | 1 | 22-May-2004 11:28 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The