(ES6) ES6 (2016)

TypedArr (TB03)

   1:  const buffer = new ArrayBuffer(4); // 4 bytes for a 32-bit float
   2:  const view = new DataView(buffer);
   3:  
   4:  // Write a 32-bit float in little-endian format
   5:  view.setFloat32(0, 123.45, true); // true for little-endian
   6:  
   7:  // Read the 32-bit float in little-endian format
   8:  const littleEndianValue = view.getFloat32(0, true);
   9:  console.log(littleEndianValue); // Output: 123.45
  10:  
  11:  // Read the 32-bit float in big-endian format
  12:  const bigEndianValue = view.getFloat32(0, false);
  13:  console.log(bigEndianValue); // Output: A very different number (due to endianness)



Writing and Reading a Float (32-bit)

123.44999694824219
5.453434729516787e+23





TypedArr context:






ES6 context:




Binary context:



Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23>  <24>  <25
Link to this page: http://www.vb-net.com/JavascriptES6/TB03.htm
<TAGS>  <ARTICLES>  <FRONT>  <CORE>  <MVC>  <ASP>  <NET>  <DATA>  <TASK>  <XML>  <KIOSK>  <NOTES>  <SQL>  <LINUX>  <MONO>  <FREEWARE>  <DOCS> <TRAVELS> <FLOWERS> <RESUME> < THANKS ME>