Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / November 2005

Tip: Looking for answers? Try searching our database.

Big Number Library Error

Thread view: 
toy - 08 Nov 2005 02:47 GMT
BigInteger d;
  int f = 256;
  BigInteger g = 101;
  BigInteger st = TWO.pow(f);
  BigInteger n = st.add(g);

This is the error:
incompatible types
found   : int
required: java.math.BigInteger
  BigInteger g = 101;
                 ^
1 error

Basically I need the big num library to compute 2^(255)+101 and store
that in the variable n...what do I do?
Thomas Schodt - 08 Nov 2005 09:49 GMT
> Basically I need the big num library to compute 2^(255)+101 and store
> that in the variable n...what do I do?

Like so?

import java.math.BigInteger;
public final class Toy {
   public static final BigInteger TWO = BigInteger.ONE.shiftLeft(1);
   public static final BigInteger ONEHUNDREDONE = new BigInteger("101");
   public static final BigInteger twoPower255plus101 =
      TWO.shiftLeft(255-1).add(ONEHUNDREDONE);
   public static final void main(String[] arg) {
      System.out.println(twoPower255plus101.toString(16));
   }
}


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.