gdxapp4d/core/src/love/distributedrebirth/numberxd/GroßGetậl1D.java

100 lines
2.6 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.BaseNumberTyte;
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-30 20:50:19 +00:00
public class GroßGetậl1D implements BaseNumberTyte<GroßGetậl1D> {
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];
2022-01-30 20:50:19 +00:00
public GroßGetậl1D() {
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();
}
}
2022-01-30 20:50:19 +00:00
public GroßGetậl1D(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);
}
}
2022-01-30 20:50:19 +00:00
public GroßGetậl1D(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();
}
}
2022-01-30 20:50:19 +00:00
public GroßGetậl1D(V090Tocta tocta) {
2022-01-28 10:24:54 +00:00
List<V009Tyte> tytes = new ArrayList<>();
tocta.fillTyteValues(new V009TyteBaseAppender(tytes));
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-30 14:27:57 +00:00
public V090Tocta toTocta() {
return new V090Tocta(cloneIterator());
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
2022-01-30 20:50:19 +00:00
public GroßGetậl1D toClone() {
return new GroßGetậl1D(cloneIterator());
2022-01-30 10:28:52 +00:00
}
@Override
public void fillOctalValues(T08PartOctalBaseAppender appender) {
for (int i=0;i<NUMERATOR_SIZE;i++) {
numerator[i].fillOctalValues(appender);
}
for (int i=0;i<DENOMINATOR_SIZE;i++) {
denominator[i].fillOctalValues(appender);
}
}
@Override
public void fillTyteValues(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
}
}
}