Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Fairly new to Java, need help with bigIntegers

ryman_2000ryman_2000 Member Posts: 27
Hi,

I'm trying to make an RSA decrypt program, but before I can do that, I want to make a simple test program. The Values are going to be Hex. Here is what I did:

import java.math.BigInteger;
public class Math {
public static void main (String[]args) {
BigInteger x= new BigInteger("abcde343cdef",16);
BigInteger y =new BigInteger("abc432bcdef",16);
BigInteger a = x.add(y);
System.out.println (a);
}
}

This program will print the results to the screen, but in Decimal. I want everything to be done in Hex. If i take the 16s off, I get an error, and I don't really know how to use the 0x (I just got errors, this is the only program that wont get errors)

Also, could you please tell me how to do "to the power of" with large hex numbers and "mod" with large hex numbers. I've been trying everything but can't get it to print out hex numbers. Thanks in advance,

ryman_2000

Comments

  • TenLeftFingersTenLeftFingers Member Posts: 74
    Try this "Java Gotcha's" site

    http://mindprod.com/gotchas.html

    I had a quick look, but I'm new to Java myself 8)~

    TenLeftFingers
  • ryman_2000ryman_2000 Member Posts: 27
    I didn't see anything on that page that I could really use. Does anyone else have some information for me? Thanks,

    ryman_2000
  • Shawn CarterShawn Carter Member Posts: 0

    __ < http://forcoder.org /> free ebooks and video tutorials about | Scratch PL/SQL Go MATLAB Visual Basic .NET Perl Ruby Delphi PHP C++ Python Visual Basic C# Objective-C C JavaScript Swift Java Assembly R SAS Dart Scheme Logo COBOL F# Ada Transact-SQL Kotlin Crystal Lua FoxPro Fortran Clojure VBScript Prolog Julia Erlang Bash Alice Hack ABAP Scala Lisp ML Awk Apex LabVIEW Rust D |

Sign In or Register to comment.