🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #336

Re: Help Needed please

#336
From: Tobias Brummund
Date: Mon, 23 Oct 2000 00:00
48 lines
1594 bytes
Livio Colbertaldo wrote:
> 
> i have this peice of code when i adjust the values n1 and e1 to bigger
> values all i get on the result is 0
> can neone please tell me what im doin wrong and how to fix it
> thank you
> public String ab1() {
>  double n1,e1,s7;
>  int s2;
>  Integer ab3;
>  String s5=new String();
> n1=1000;
> e1=1000;
> s2=97;
> 
>  s7=Math.pow(s2,e1)%n1;
>  ab3=new Integer(new Double(s7).intValue());
>  s5=ab3.toString();
>  return s5;;
> 
> }

Hello !

I think this code will do what you want:

public String ab1()
{
  int n1=1000 ,e1=1000;
  BigInteger s1 = new BigInteger(97+"");
  BigInteger bi;
  bi = s1.modPow(new BigInteger(e1+""), new BigInteger(n1+""));
  return bi+"";
}

You must import java.math.*

Your problem was that you exceeded the range of double and int.

+"" is equal to .toString()

Greetings,
Tobias Brummund
-- 
______________________________________________
Wasserpflanzen & japanische Wasserfl�he unter:

  http://www-public.tu-bs.de:8080/~y0008601
Technical Details
Message-ID: <39F36C2B.5F7F903F@uni.de>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <Ew7I5.2495$SF5.58944@ozemail.com.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10d6db,9f36909a69e4ec54
X-Google-Attributes: gid10d6db,public
From: Tobias Brummund <t.brummund@uni.de>
Subject: Re: Help Needed please
Date: 2000/10/23
Message-ID: <39F36C2B.5F7F903F@uni.de>
X-Deja-AN: 684585760
Content-Transfer-Encoding: 8bit
References: <Ew7I5.2495$SF5.58944@ozemail.com.au>
X-Accept-Language: en
Content-Type: text/plain; charset=iso-8859-1
X-Trace: fu-berlin.de 972254256 22595403 193.158.191.225 (16 [51559])
Mime-Version: 1.0
Newsgroups: aus.computers.java