Skip to content

Commit f29e89c

Browse files
Large numbers
1 parent b1ad614 commit f29e89c

File tree

5 files changed

+141
-0
lines changed

5 files changed

+141
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import java.math.BigInteger;
2+
3+
class Factorial {
4+
5+
static BigInteger fact(int num) {
6+
BigInteger ans = new BigInteger("1");
7+
8+
for (int i=2; i<= num; i++) {
9+
ans = ans.multiply(BigInteger.valueOf(i));
10+
}
11+
12+
return ans;
13+
}
14+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import java.math.BigInteger;
2+
import java.math.BigDecimal;
3+
4+
class Main {
5+
public static void main(String[] args) {
6+
BD();
7+
}
8+
9+
static void BD() {
10+
double x = 0.03;
11+
double y= 0.04;
12+
// double ans = y-x;
13+
// System.out.println(ans);
14+
15+
BigDecimal X = new BigDecimal("0.03");
16+
BigDecimal Y = new BigDecimal("0.04");
17+
BigDecimal ans = Y.subtract(X);
18+
// System.out.println(ans);
19+
20+
BigDecimal a = new BigDecimal("456576345675.4546376");
21+
BigDecimal b = new BigDecimal("547634565352.986785764");
22+
23+
// operations
24+
System.out.println(b.add(a));
25+
System.out.println(b.subtract(a));
26+
System.out.println(b.multiply(a));
27+
System.out.println(b.pow(2));
28+
System.out.println(b.negate());
29+
30+
// constants
31+
BigDecimal con = BigDecimal.ONE;
32+
33+
}
34+
35+
36+
static void BI() {
37+
int a = 30;
38+
int b = 67;
39+
40+
BigInteger B = BigInteger.valueOf(6); // convert int/long to BI
41+
int c = B.intValue(); // convert BI to int
42+
BigInteger C = new BigInteger("2345678654325678976543256789");
43+
BigInteger X = new BigInteger("4536789765432");
44+
45+
// constants
46+
BigInteger D = BigInteger.TEN;
47+
48+
// operations
49+
BigInteger s = C.add(X);
50+
51+
BigInteger m = C.multiply(X);
52+
53+
BigInteger sub = C.subtract(X);
54+
55+
BigInteger d = C.divide(X);
56+
57+
BigInteger rem = C.remainder(X);
58+
59+
if (X.compareTo(C) < 0) {
60+
System.out.println("Yes");
61+
}
62+
63+
System.out.println(Factorial.fact(100));
64+
}
65+
66+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<project>
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>mygroupid</groupId>
4+
<artifactId>myartifactid</artifactId>
5+
<version>0.0-SNAPSHOT</version>
6+
<dependencies>
7+
<dependency>
8+
<groupId>junit</groupId>
9+
<artifactId>junit</artifactId>
10+
<version>4.12</version>
11+
<type>jar</type>
12+
</dependency>
13+
<dependency>
14+
<groupId>com.googlecode.json-simple</groupId>
15+
<artifactId>json-simple</artifactId>
16+
<version>1.1.1</version>
17+
<type>jar</type>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.hamcrest</groupId>
21+
<artifactId>hamcrest-core</artifactId>
22+
<version>1.3</version>
23+
<type>jar</type>
24+
</dependency>
25+
</dependencies>
26+
<build>
27+
<plugins>
28+
<plugin>
29+
<groupId>de.qaware.maven</groupId>
30+
<artifactId>go-offline-maven-plugin</artifactId>
31+
<version>1.2.5</version>
32+
<configuration>
33+
<dynamicDependencies>
34+
<DynamicDependency>
35+
<groupId>org.apache.maven.surefire</groupId>
36+
<artifactId>surefire-junit4</artifactId>
37+
<version>2.20.1</version>
38+
<classifier></classifier>
39+
<repositoryType>PLUGIN</repositoryType>
40+
</DynamicDependency>
41+
<DynamicDependency>
42+
<groupId>com.querydsl</groupId>
43+
<artifactId>querydsl-apt</artifactId>
44+
<version>4.2.1</version>
45+
<classifier>jpa</classifier>
46+
<repositoryType>MAIN</repositoryType>
47+
</DynamicDependency>
48+
</dynamicDependencies>
49+
</configuration>
50+
</plugin>
51+
</plugins>
52+
</build>
53+
</project>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{ pkgs }: {
2+
deps = [
3+
pkgs.graalvm17-ce
4+
pkgs.maven
5+
pkgs.replitPackages.jdt-language-server
6+
pkgs.replitPackages.java-debug
7+
];
8+
}
Binary file not shown.

0 commit comments

Comments
 (0)