gdxapp4d/numberxd/src/main/love/distributedrebirth/numberxd/GroßGetậl1ⁿᴰ.java

102 lines
2.7 KiB
Java
Raw Normal View History

2022-01-30 21:00:16 +00:00
package love.distributedrebirth.numberxd;
2022-01-28 10:24:54 +00:00
import java.util.ArrayList;
import java.util.List;
2022-01-30 21:00:16 +00:00
import love.distributedrebirth.numberxd.base2t.T08PartOctalBaseAppender;
import love.distributedrebirth.numberxd.base2t.T08PartOctalBaseIterator;
import love.distributedrebirth.numberxd.base2t.V009Tyte;
import love.distributedrebirth.numberxd.base2t.V009TyteBaseAppender;
import love.distributedrebirth.numberxd.base2t.V009TyteBaseIterator;
import love.distributedrebirth.numberxd.base2t.V090Tocta;
2022-01-28 10:24:54 +00:00
/**
2022-01-30 20:50:19 +00:00
* Holds an 144 bit fraction.
*
* @author willemtsade ©Δ 仙上主天
*/
2022-01-31 18:06:09 +00:00
public class GroßGetậl1ⁿᴰ implements BaseGetậl<GroßGetậl1ⁿᴰ> {
2022-01-28 10:24:54 +00:00
public static int NUMERATOR_SIZE = 7;
public static int DENOMINATOR_SIZE = 9;
2022-01-30 20:50:19 +00:00
public static int BIT_COUNT = V090Tocta.BIT_COUNT;
2022-01-28 10:24:54 +00:00
private final V009Tyte[] numerator = new V009Tyte[NUMERATOR_SIZE];
private final V009Tyte[] denominator = new V009Tyte[DENOMINATOR_SIZE];
public GroßGetậl1ⁿᴰ() {
2022-01-28 10:24:54 +00:00
for (int i=0;i<NUMERATOR_SIZE;i++) {
numerator[i] = new V009Tyte();
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
denominator[i] = new V009Tyte();
}
}
public GroßGetậl1ⁿᴰ(T08PartOctalBaseIterator values) {
2022-01-30 10:28:52 +00:00
for (int i=0;i<NUMERATOR_SIZE;i++) {
numerator[i] = new V009Tyte(values);
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
denominator[i] = new V009Tyte(values);
}
}
public GroßGetậl1ⁿᴰ(V009TyteBaseIterator values) {
2022-01-30 10:28:52 +00:00
for (int i=0;i<NUMERATOR_SIZE;i++) {
numerator[i] = values.next();
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
denominator[i] = values.next();
}
}
public GroßGetậl1ⁿᴰ(V090Tocta tocta) {
2022-01-28 10:24:54 +00:00
List<V009Tyte> tytes = new ArrayList<>();
2022-01-31 12:15:04 +00:00
tocta.fillTytesByReference(new V009TyteBaseAppender(tytes));
2022-01-28 10:24:54 +00:00
for (int i=0;i<NUMERATOR_SIZE;i++) {
numerator[i] = tytes.get(i);
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
denominator[i] = tytes.get(i+NUMERATOR_SIZE);
}
}
2022-01-31 12:15:04 +00:00
public V090Tocta toToctaByReference() {
return new V090Tocta(iteratorTytesByReference());
}
public V090Tocta toToctaByClone() {
return new V090Tocta(iteratorOctalsByClone());
2022-01-30 10:28:52 +00:00
}
@Override
public int getBitCount() {
2022-01-30 14:27:57 +00:00
return V090Tocta.BIT_COUNT;
2022-01-30 10:28:52 +00:00
}
@Override
public GroßGetậl1ⁿᴰ toClone() {
return new GroßGetậl1ⁿᴰ(iteratorOctalsByClone());
2022-01-30 10:28:52 +00:00
}
@Override
2022-01-31 12:15:04 +00:00
public void fillOctalsByClone(T08PartOctalBaseAppender appender) {
2022-01-30 10:28:52 +00:00
for (int i=0;i<NUMERATOR_SIZE;i++) {
2022-01-31 12:15:04 +00:00
numerator[i].fillOctalsByClone(appender);
2022-01-30 10:28:52 +00:00
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
2022-01-31 12:15:04 +00:00
denominator[i].fillOctalsByClone(appender);
2022-01-30 10:28:52 +00:00
}
}
@Override
2022-01-31 12:15:04 +00:00
public void fillTytesByReference(V009TyteBaseAppender appender) {
2022-01-28 10:24:54 +00:00
for (int i=0;i<NUMERATOR_SIZE;i++) {
2022-01-30 10:28:52 +00:00
appender.add(numerator[i]);
2022-01-28 10:24:54 +00:00
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
2022-01-30 10:28:52 +00:00
appender.add(denominator[i]);
2022-01-28 10:24:54 +00:00
}
}
}