MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / fromBytes

Method fromBytes

lib.commonjs/utils/fixednumber.js:515–523  ·  view source on GitHub ↗

* Creates a new [[FixedNumber]] with the big-endian representation * %%value%% with %%format%%. * * This will throw a [[NumericFaultError]] if %%value%% cannot fit * in %%format%% due to overflow.

(_value, _format)

Source from the content-addressed store, hash-verified

513 * in %%format%% due to overflow.
514 */
515 static fromBytes(_value, _format) {
516 let value = (0, maths_js_1.toBigInt)((0, data_js_1.getBytes)(_value, "value"));
517 const format = getFormat(_format);
518 if (format.signed) {
519 value = (0, maths_js_1.fromTwos)(value, format.width);
520 }
521 checkValue(value, format, "fromBytes");
522 return new FixedNumber(_guard, value, format);
523 }
524}
525exports.FixedNumber = FixedNumber;
526//const f1 = FixedNumber.fromString("12.56", "fixed16x2");

Callers

nothing calls this directly

Calls 2

getFormatFunction · 0.70
checkValueFunction · 0.70

Tested by

no test coverage detected