Buffer.readBigInt64LE()方法用於以給定的偏移量從緩衝區對象讀取64位Big整數,並以Little Endian返回結果。
用法:
buffer.readBigInt64LE( offset )
參數:此方法接受單個參數偏移量,該偏移量指定緩衝區對象的位置。它表示開始讀取之前要跳過的字節數。 offset的值在0到buffer.length-8的範圍內。默認值為0。
返回值:此方法在Little endian中的指定偏移處讀取帶符號的64位Big整數。
範例1: 文件名:index.js
// Node.js program to demonstrate the
// buffer.readInt32LE() method
const buff = Buffer.from([0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
// Getting big integer value by
// using readBigInt64LE method
const value = buff.readBigInt64LE(0);
// Display the result
console.log("Big Interger:- " + value);
使用以下命令運行index.js文件:
node index.js
輸出:
Big Interger:- -4294967296
範例2:
文件名:index.js
// Node.js program to demonstrate the
// buffer.readInt32LE() method
const buff = Buffer.from([0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0xff]);
// Getting big interger value by
// using readBigInt64LE method
const value = buff.readBigInt64LE(1);
// Display the result
console.log("Big Interger:- " + value);
使用以下命令運行index.js文件:
node index.js
輸出:
internal/buffer.js:77 throw new ERR_OUT_OF_RANGE(type || 'offset', ^ RangeError [ERR_OUT_OF_RANGE]:The value of "offset" is out of range. It must be >= 0 and <= 0. Received 1 at boundsError (internal/buffer.js:77:9) at Buffer.readBigInt64LE (internal/buffer.js:128:5) at Object. (F:\java\GFG.js:7:20) at Module._compile (internal/modules/cjs/loader.js:1138:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) at Module.load (internal/modules/cjs/loader.js:986:32) at Function.Module._load (internal/modules/cjs/loader.js:879:14) at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) at internal/main/run_main_module.js:17:47 { code:'ERR_OUT_OF_RANGE' }
上麵的示例顯示了錯誤,因為其參數不在有效範圍內。
參考: https://nodejs.org/dist/latest-v12.x/docs/api/buffer.html#buffer_buf_readbigint64le_offset
相關用法
- Node.js console.timeLog()用法及代碼示例
- Node.js GM write()用法及代碼示例
- Node.js GM operator()用法及代碼示例
- Node.js GM randomThreshold()用法及代碼示例
- Node.js GM negative()用法及代碼示例
- Node.js GM median()用法及代碼示例
- Node.js GM crop()用法及代碼示例
- Node.js GM despeckle()用法及代碼示例
- Node.js GM emboss()用法及代碼示例
- Node.js GM whitePoint()用法及代碼示例
- Node.js GM drawRectangle()用法及代碼示例
- Node.js GM shave()用法及代碼示例
- Node.js GM recolor()用法及代碼示例
- Node.js GM gamma()用法及代碼示例
注:本文由純淨天空篩選整理自RohitPrasad3大神的英文原創作品 Node.js Buffer.readBigInt64LE() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。