/** * Convert {@link BValueArray} to JSON. * * @param floatArray {@link BValueArray} to be converted to JSON * @return JSON representation of the provided floatArray */ private static BValueArray convertFloatArrayToJSON(BValueArray floatArray) { BValueArray json = new BValueArray(new BArrayType(BTypes.typeJSON)); for (int i = 0; i < floatArray.size(); i++) { double value = floatArray.getFloat(i); json.append(new BFloat(value)); } return json; }
public static BRefType<?> execListGetOperation(BNewArray array, long index) { if (array.getType().getTag() != TypeTags.ARRAY_TAG) { BValueArray bRefValueArray = (BValueArray) array; return bRefValueArray.getRefValue(index); } switch (((BArrayType) array.getType()).getElementType().getTag()) { case TypeTags.BOOLEAN_TAG: BValueArray bBooleanArray = (BValueArray) array; int i = bBooleanArray.getBoolean(index); return i == 0 ? new BBoolean(false) : new BBoolean(true); case TypeTags.BYTE_TAG: BValueArray bByteArray = (BValueArray) array; return new BByte(bByteArray.getByte(index)); case TypeTags.FLOAT_TAG: BValueArray bFloatArray = (BValueArray) array; return new BFloat(bFloatArray.getFloat(index)); case TypeTags.DECIMAL_TAG: BValueArray bDecimalArray = (BValueArray) array; return new BDecimal(new BigDecimal(bDecimalArray.getRefValue(index).stringValue())); case TypeTags.INT_TAG: BValueArray bIntArray = (BValueArray) array; return new BInteger(bIntArray.getInt(index)); case TypeTags.STRING_TAG: BValueArray bStringArray = (BValueArray) array; return new BString(bStringArray.getString(index)); default: BValueArray bRefValueArray = (BValueArray) array; return bRefValueArray.getRefValue(index); } }
arrayData = new Double[arrayLength]; for (int i = 0; i < arrayLength; i++) { arrayData[i] = ((BValueArray) value).getFloat(i);
break; case TypeTags.FLOAT_TAG: paramValue = new BFloat(((BValueArray) value).getFloat(i)); break; case TypeTags.STRING_TAG:
@Override public BValue getBValue(long index) { if (elementType != null) { if (elementType.getTag() == TypeTags.INT_TAG) { return new BInteger(getInt(index)); } else if (elementType.getTag() == TypeTags.BOOLEAN_TAG) { return new BBoolean(getBoolean(index) == 1); } else if (elementType.getTag() == TypeTags.BYTE_TAG) { return new BByte(getByte(index)); } else if (elementType.getTag() == TypeTags.FLOAT_TAG) { return new BFloat(getFloat(index)); } else if (elementType.getTag() == TypeTags.STRING_TAG) { return new BString(getString(index)); } else { return getRefValue(index); } } return getRefValue(index); }
bValueArray = Optional.of((BValueArray) sf.refRegs[i]).get(); try { sf.doubleRegs[k] = bValueArray.getFloat(sf.longRegs[j]); } catch (BallerinaException e) { ctx.setError(BLangVMErrors.createError(ctx, e.getMessage(), e.getDetail()));
double[] percentiles = new double[(int) bFloatArray.size()]; for (int j = 0; j < bFloatArray.size(); j++) { percentiles[j] = bFloatArray.getFloat(j);
BValueArray valueArray = (BValueArray) bValue; for (int i = 0; i < valueArray.size(); i++) { output.writeDouble(fieldDescriptor.getNumber(), valueArray.getFloat(i)); for (int i = 0; i < valueArray.size(); i++) { output.writeFloat(fieldDescriptor.getNumber(), Float.parseFloat(String.valueOf (valueArray.getFloat(i))));
arrayData = new Double[arrayLength]; for (int i = 0; i < arrayLength; i++) { arrayData[i] = ((BValueArray) value).getFloat(i);
BValue value = serializer.toBValue(array.getFloat(i), Double.class); target.add(i, (BRefType) value);
for (int i = 0; i < valueArray.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeDoubleSize(fieldDescriptor .getNumber(), valueArray.getFloat(i)); for (int i = 0; i < valueArray.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeFloatSize(fieldDescriptor .getNumber(), (float) valueArray.getFloat(i));