MCPcopy Create free account
hub / github.com/apache/fory / writeSliInt64

Method writeSliInt64

javascript/packages/core/lib/writer/index.ts:149–165  ·  view source on GitHub ↗
(v: bigint | number)

Source from the content-addressed store, hash-verified

147 }
148
149 writeSliInt64(v: bigint | number) {
150 if (v <= HalfMaxInt32 && v >= HalfMinInt32) {
151 // write:
152 // 00xxx -> 0xxx
153 // 11xxx -> 1xxx
154 // read:
155 // 0xxx -> 00xxx
156 // 1xxx -> 11xxx
157 this.dataView.setUint32(this.cursor, Number(v) << 1, true);
158 this.cursor += 4;
159 } else {
160 const BIG_LONG_FLAG = 0b1; // bit 0 set, means big long.
161 this.dataView.setUint8(this.cursor, BIG_LONG_FLAG);
162 this.cursor += 1;
163 this.writeVarInt64(BigInt(v));
164 }
165 }
166
167 /**
168 * Write signed long using fory Tagged(Small long as int) encoding.

Callers

nothing calls this directly

Calls 2

writeVarInt64Method · 0.95
NumberClass · 0.85

Tested by

no test coverage detected