From 6661d7997134e9be26d6f42719c2613781f19f98 Mon Sep 17 00:00:00 2001 From: k-ueda Date: Tue, 13 Feb 2024 21:08:23 +0900 Subject: [PATCH] allow 64-bit integers --- src/runtime/functor/Functor.java | 2 +- src/runtime/functor/IntegerFunctor.java | 10 +++++----- src/util/Util.java | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/runtime/functor/Functor.java b/src/runtime/functor/Functor.java index 8eb141f3..f5dcbcb2 100644 --- a/src/runtime/functor/Functor.java +++ b/src/runtime/functor/Functor.java @@ -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 { diff --git a/src/runtime/functor/IntegerFunctor.java b/src/runtime/functor/IntegerFunctor.java index 8e2e4495..2c26e434 100644 --- a/src/runtime/functor/IntegerFunctor.java +++ b/src/runtime/functor/IntegerFunctor.java @@ -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; } @@ -46,7 +46,7 @@ public String toString() { } public String getName() { - return Integer.toString(value); + return Long.toString(value); } public String getQuotedAtomName() { diff --git a/src/util/Util.java b/src/util/Util.java index f263a8fd..6669749a 100644 --- a/src/util/Util.java +++ b/src/util/Util.java @@ -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) { @@ -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); } @@ -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) { @@ -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); }