Parsing long numbers very huge

Hi all:
How i can parse a long number like this:
String variable="E898374636475837";
long v=Long.parseLong(variable);
This code throw:
Exception in thread "main" java.lang.NumberFormatException: E898374636475837
at java.lang.Long.parseLong(Long.java:310)
at java.lang.Long.parseLong(Long.java:363)
at q.main(q.java:6)
Please help me, I nedd parse many DES keys entered by the user keyboard.
Thanks.

The long number is very huge.
Long number can store only 2 to the power 64 's
value.But not that huge.... The range of long is from -2^63 to 2^63-1. The value here is not in that range.
You'll need the class java.math.BigInteger to represent that value and it also has parsing methods of it's own; check the docs.

Similar Messages

  • Parsing long numbers as strings

    Hi
    Is there any way you can prevent a long number being converted to scientific notation? I have to write a method that substrs out each numeric character from a long positive whole number but when the number gets lon it falls over as the number is converted to scientific notation containing '.' and 'E' etc
    Any help would be appreciated
    Cheers

    Hi guys
    Thanks for the replies. I think the FM with 63 9s will probably be the simplest.
    I'm sorry I wasn't able to post an example as I was just heading out of the office for the day, but have got home so, for completeness will try to pen an example...although I don't have a server here so will be guessing syntax etc :-)
    Please forgive me if it doesn't run first time, but it should convey the intention...if necessary I'll debug it in the morning.
    Cheers
    declare
    mystring varchar2(1000) := '9999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999';
    thisnum number;
    retnum number := 0;
    k number;
    begin
    k:=1;
    while k >0 loop
    for i in 1...length(mystring) loop
    thisnum != to_number(substr(mystring,i,1));
    retnum := retnum +thisnum;
    end loop;
    if length(retnum) > 60 then
    mystring := 'retnum';
    else
    k :=0;
    end if;
    end loop;
    --in the real case the retnum value would be stored at this point
    end;
    the 'while' loop if needed for very long strings where the 'addition' step hasn't decreased the length enough to be parsed as a number, the problem I have encountered only happens when the resulting number from the first run is long enough for an implicit conversion to scientific notation, this example may not be long enough to trigger it.

  • My Apple iPad 3 is less than 6 months old - purchased in March of 2012.  I believe it already needs a new battery.  It will not hold a charge for very long andvs very slow in starting up a carge when I plug it in.  Please advise - it is very annoying.n.

    My Apple iPad 3 is less than 6 months old - purchased in March of 2012.  I believe it already needs a new battery.  It will not hold a charge for very long andvs very slow in starting up a carge when I plug it in.  Please advise - it is very annoying.

    Take it to Apple Store. You are covered under your 1 year warranty.

  • I have a long numbers document, that I'd like to make more print friendly. It is a list of my DVD's that I just listed one after the other (1-200) when I tried to print it, it would be 18 pages, can I change it to be more like columns side by side to save

    I have a long numbers document, that I'd like to make more print friendly.
    It is a list of my DVD's that I just listed one after the other (1-200) when I tried to print it, it would be 18 pages,
    can I change it to be more like columns side by side to save paper?

    S,
    I assume that you also have Pages on your computer (or some other capable WP program). I also assume that you have eliminated any unnecessary columns, so you have a 1-column table in Numbers.
    When it comes time to print, Copy the entire Table: Click on the table name in the Sheets Pane and Command-C.
    Switch to Pages, open a blank WP template and set the number of columns to 3 or so. With the Text Insertion Cursor flashing on the first line of the first column of the blank template, Command-V. Your table should paste into the Pages document as an Inline Object and will Wrap on the page as you desire. Then Print in Pages.
    Jerry

  • How to open a very huge HFR recording using JRMC?

    When trying to open a HUGE JFR recording of size 500 mg using JRMC, it is throwing Out Of Memory error.
    How to open a very huge HFR recording using JRMC?
    Any clues?

    You can try to start mission control by using the command line and defining more memory for the JVM it is running in, for example,
    java -Xms1024m -Xmx1024m -jar <JROCKIT_HOME>/missioncontrol/mc.jar
    Of course you can incease the Xms and Xmx values

  • Parsing hexadecimal long very huge numbers

    Hi all:
    How i can parse a hexadecimal long number like this:
    String variable="E898374636475837";
    long v=Long.parseLong(variable, 16);
    This code throw:
    Exception in thread "main" java.lang.NumberFormatException: E898374636475837
    at java.lang.Long.parseLong(Long.java:322)
    at q.main(q.java:6)
    The problem is with numbers greater than
    1FFFFFFFFFFFFFFF
    Please help me, I nedd parse many DES keys entered by the user keyboard.
    Thanks.

    Try this out,
    System.out.println(new java.math.BigInteger("E898374636475837", 16));
    Hope this works out for you.
    Regards
    Omer

  • Problem in Downloading Word Document of very huge size

    Hi Folks,
    I upload a word document of 5 MB size to the server. I do hexencoding before
    I upload. The problem is when i try to download the file from the server it
    goes on parsing the document and it does'nt stop. It is getting stuck in
    the while loop. I am using BufferedInputStream for reading the data and
    storing it in a String. Even the CPU utilization stays at 100% in Task Manager.
    Can any of you Suggest a solutation? Should I replace BufferedInputStream with
    some other class.
    Thanks in advance.
    -deena

    No wonder it takes long or even seems that it hangs... Your going to use incredible amount of memory within that loop. First of all you recreate your buffer every time, but then you create new string of it, and then concat it to other, which will again create new string. Stringbuffer will probably help, but it's still a waste.
    try this:
    byte inbuffer[]=new buffer[BUFSIZE];
    byte outbuffer[]=new buffer[BUFSIZE/2];
    int readed;
    while ( (readed=in.read(buffer))!=0)
       hexEncode(outbuffer, inbuffer, readed); // or whatever way you do it
       out.write(outbuffer, 0, readed); // or whereever you want to put the data
    }Anyway the idea is to use common input and output buffer so memory isn't wasted. This is based on a fact that InputStreams read suplied only with byte[] argument read's as much as possible from stream and return the amount of bytes read.

  • Numbered list is automatically formatting the numbers very large & bold

    I am trying to create a document using Pages which has several lists in it. When I choose "List, numbered" from the menu in the inspector, the numbers are extremely large & bold. I want them to match the font I am using in the document (Helvetica 12 pt.).
    I was able to get this working last night earlier in the document, but now I can't remember what I did. I don't see a "Format numbering" command anywhere.
    This is very frustrating, as it should be easy to do. As much as I hate using Microsoft Word, I'm starting to think that I need to go back to it, as making lists is much easier to do, and I don't have to spend an hour making a short 10-item list!!
    Can anyone help me on this??

    Select all (which selects the text body as well as the numbering)
    Apply size - 12 points.
    will do the trick.
    The only way I was able to reproduce the described behavior was to
    select all, set size to 36 points
    Then, use the mouse to select from the beginning to the end and set font size to 12.
    This late protocol selects only the typed text, not the numbering which is not stored in the text body.It's not a clone of "Select All".
    Yvan KOENIG (from FRANCE samedi 23 août 2008 16:25:06)

  • Call history gone - red long numbers

    Hello, since I've updated to iOS 8 my call history is gone.
    There's also a very long number insight the red bubble in the right top corner.
    I've also experienced the problem when somebody's call me and I missed it, the missed call isn't showed anymore in my lock screen.
    I backed up my iPhone 4S two times and made a clean install. But the problem is still there.
    Anybody with the same problems? Any solutions?

    The activity you're seeking is available to you when you log on to My Verizon using the Account Owner's profile. If you log on using an Account User profile, your options will be limited. Once you log on using the Account Owner's profile, look to the right side of the home screen for a button that reads "View Bill". Click on that button and it will take you to a page where you can view Usage Details. 

  • Parsing Phone Numbers

    Hello,
    We are working on an integration that needs the phone numbers in CRMOD parsed out into the individual components. Currently the Web Services provide a phone number in it's full form. We would like to get the country code, area code, phone number, and extension as separate values. In CRMOD this is automatically done when you click on the "phone" icon. I'm not sure if CRMOD stores these values separately, or if this is just an algorithm. If it is an algorithm, has anyone re-created it?
    Thanks.
    Neal G.

    Check out the following template from metalink.
    Address Mapping Template and Phone Mapping Guide (Doc ID 556551.1)

  • Parsing localized numbers

    I'm trying to use NumberFormat to validate a string containing a formatted number but having a lot of problems. First, invalid strings are just ignored (same thing as http://forum.java.sun.com/thread.jsp?forum=31&thread=157703)
    Also in French, space is used as thousands separators, however if I use a string with space only only the thousands are parsed, i.e.:
    String value = "1 234,45";
    try {
       Number number = NumberFormat.getNumberInstance(Locale.FRENCH).parse(value);
    System.out.println(number.floatValue());
    } catch (ParseException e) {
       e.printStackTrace();
    }The output:
    1.0
    Any help? Thanks!

    With the NumberFormat, you will get an exception only if the very first character is not parseable. But you don't have to write your own parse routine, just do this:
    import java.text.*;
    import java.util.*;
    public class number {
       public static void main(String[] args) {
          try {
             DecimalFormatSymbols df = new DecimalFormatSymbols(Locale.FRENCH);
             df.setDecimalSeparator(',');
             df.setGroupingSeparator(' ');
             DecimalFormat NF=new DecimalFormat("#,###.##",df);
             String out=NF.format(-1234.56);
             System.out.println(out);
             ParsePosition PP=new ParsePosition(0);
             Number number = NF.parse(args[0],PP);
             if (PP.getIndex()!=args[0].length()) System.out.println("Parse Exception");
             System.out.println(number);
          } catch (Throwable exception) {
             exception.printStackTrace();
    }V.V.

  • Best parser for handling very large XML  document

    which is the best parser whenread and extract information from very large XML document

    Any SAX-parser, since DOM would use 6 times as much primary memory as the file-size.
    Xerces SAX-parser is in my experience the fastest.
    Gil

  • Numbers VERY slow updating to idrive

    I Changed the names for 10 spreadsheets and sfter
    3,5 hours Numbers still says:
    "Updating 10 sheets"
    I have 100MBS FIBER (25 on iPad wifi)

    Thanks Wayne,
    I did many times shut down &amp; restart, but openning numbers still very slow.
    Is it maybe due to some large files inside my numbers ? (My spreadsheet = BF column &amp; 315 row).
    Or is it Numbers are made for very light use only ?
    Pls reply if possible. Tks.

  • Upgraded to io7 and my passcode is no longer numbers, but the keyboard

    I upgraded the software on my 4S. My lock screen used to be a 4 number passcode, and now the lock screen has the full keyboard and I must type in my "find my iphone" password. How can I change it back to the 4 numbers?

    It's not clear whether your printer is included in the Apple list - there is an Officejet 6100 and a couple of other types. Go to the page linked to above and use the browser search for 6100.
    I'm afraid HP are notorious for not supporting older printers - I had the same problem. Probably they hope you will buy another printer (I did, but it was a Canon). I did look on HP's site and couldn't see a driver - you could give it a try (make sure you have the exactly correct printer name):
    http://www8.hp.com/uk/en/support-search.html?tab=1#/qryterm=HP6100&search_search type=s-002
    Alternatively ou could try Gutenprint (open source software):
    http://gimp-print.sourceforge.net/MacOSX.php
    I found it would indeed drive the printer, but the colour dithering wasn't very satisfactory and the duplex printing bolt-on wouldn't work. However as Gutenprint is free it's worth trying to see if it's any good for you.

  • Parsing Double numbers

    I am trying to write a program for some maths coursework,and I am having problems compiling it on my laptop,but I can compile it on the university unix machines!
    Specifically,the line of code that appears to be causing the trouble is the following line of code :-
    double number = Double.parseDouble(stdin.readLine());
    When ever I try and compile the program on my laptop (it's running Windows by the way),i get an error message,saying that it cannot resolve symbol,with the ^ pointing to the full stop,ie between "Double" and "parse".
    Any help in rectifying this problem would be greatly appreciated.
    Thanks very much.

    to compile my code I am just using the command javac
    through the comman line?
    I really cant undestand the problem!Well, unfortunately javac doesn't have a -version option (at least prior to the 1.5 / 5.0 version). But I heard that the newest version does. What does javac -version display? If it doesn't show a version number but instead says something like "invalid flag: -version", then I'd guess that the version of that tool is old. Did you really install the JDK and not just JRE? Or maybe you goofed up an installation and ended up with an old javac tool in your PATH ahead of the version that you want.

Maybe you are looking for

  • Time Machine/Time Capsule backups successful, but take a long time

    I purchased a 512GB Time Capsule about a year ago. Since I got it, backups have been successful, but very slow. An average backup takes about 40-50 minutes, usually for less than 20 MB transferred. Here are a couple summaries of recent backups (see e

  • Normalising Sound Levels in iMovie

    Hello, I have an iMovie project which is a video/audio interview between two people. Unfortunately the interviewer's mic is far quieter than the interviewee's. Is there a way that I can normalise the sound levels within iMovie so that the volume is c

  • Date Unix time stamp in milli seconds

    TYPES : BEGIN OF ty_final,          line(600)  TYPE c,         END OF ty_final. DATA : gt_final TYPE TABLE OF ty_final. I have some the records are that are appending to the  internal table gt_final is of length 6423,7. How can I achieve this ? Final

  • Regarding work center configuration.

    Hi PP Gurus, We need to take an account to Rated Line Speed (Bottles per minute)  (i.e. It should be the current capacity of the bottling line operating at the full rated speed, irrespective of the bottling format). We're using Discrete Manufacturing

  • How to create new check for SELECT* , Naming conventions etc..

    Hi all,    I would like have a solution for the below checks are possible or not in ABAP - CODE INSPECTOR. If possible can you please give me the solution.. a). Performance checks i.e, SELECT* , LOOP without field strings, FOR ALL ENTRIES IN SELECT S