Skip to content

Commit

Permalink
allow 64-bit integers
Browse files Browse the repository at this point in the history
  • Loading branch information
k-ueda committed Feb 13, 2024
1 parent e16424d commit 6661d79
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/runtime/functor/Functor.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public static Functor build(String name, int arity, int nametype) {
name = name.substring(2);
radix = 16;
}
return new IntegerFunctor(Integer.parseInt(name, radix));
return new IntegerFunctor(Long.parseLong(name, radix));
} catch (NumberFormatException ignored) {
}
try {
Expand Down
10 changes: 5 additions & 5 deletions src/runtime/functor/IntegerFunctor.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
* @author n-kato */
public class IntegerFunctor extends DataFunctor {

private int value;
private long value;

public IntegerFunctor(int value) {
public IntegerFunctor(long value) {
this.value = value;
}

public int hashCode() {
return value;
return (int) value;
}

public int intValue() {
public long intValue() {
return value;
}

Expand Down Expand Up @@ -46,7 +46,7 @@ public String toString() {
}

public String getName() {
return Integer.toString(value);
return Long.toString(value);
}

public String getQuotedAtomName() {
Expand Down
8 changes: 4 additions & 4 deletions src/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public static boolean isList(Link link) {
* @return
*/
public static boolean listMax(Link link, Atom result) {
int max = Integer.MIN_VALUE;
long max = Long.MIN_VALUE;
boolean b = true;
Atom a;
while (true) {
Expand All @@ -112,7 +112,7 @@ public static boolean listMax(Link link, Atom result) {
b = false;
break;
}
int v = ((IntegerFunctor) a.nthAtom(0).getFunctor()).intValue();
long v = ((IntegerFunctor) a.nthAtom(0).getFunctor()).intValue();
if (max < v) max = v;
link = a.getArg(1);
}
Expand All @@ -127,7 +127,7 @@ public static boolean listMax(Link link, Atom result) {
* @return
*/
public static boolean listMin(Link link, Atom result) {
int min = Integer.MAX_VALUE;
long min = Long.MAX_VALUE;
boolean b = true;
Atom a;
while (true) {
Expand All @@ -143,7 +143,7 @@ public static boolean listMin(Link link, Atom result) {
b = false;
break;
}
int v = ((IntegerFunctor) a.nthAtom(0).getFunctor()).intValue();
long v = ((IntegerFunctor) a.nthAtom(0).getFunctor()).intValue();
if (min > v) min = v;
link = a.getArg(1);
}
Expand Down

0 comments on commit 6661d79

Please sign in to comment.