Node.js / V8 no real float type?

I am trying to save one value floatthrough BufferinNode.js

> f = 3.3
3.3
> var buf = new Buffer(32)
> buf.writeFloatBE(f);
4
> g = buf.readFloatBE();
3.299999952316284

Then I found the stored value gafter readFloatBE()NOT equal to the original f.

After further investigation, the two buffer values ​​stored gand fare the same.

> var buf1 = new Buffer(4); buf1.writeFloatBE(f); buf1
<Buffer 40 53 33 33>
> var buf2 = new Buffer(4); buf2.writeFloatBE(g); buf2
<Buffer 40 53 33 33>

According to this read and write buffer floats , we know what writeDoulbeBEshould be used here.

> var buf3 = new Buffer(8);
> buf3.writeDoubleBE(f);
8
> h = buf3.readDoubleBE();
3.3
> h === f
true

I want to know why the type is floatnot used in Node.jsor V8? Refer to code fromV8

  // Fast primitive setters
  V8_INLINE void Set(bool value);
  V8_INLINE void Set(double i);
  V8_INLINE void Set(int32_t i);
  V8_INLINE void Set(uint32_t i);

It seems that NO floattype is in V8, any reason for this design, or am I missing something? In this case, should this function be used writeFloatBE()?

+4
1

, V8 NO float

, : JavaScript float. double ECMAScript.

, f 3.3 double, g float. , , f. , buf.writeInt…, 3 not 3.3.

, writeFloatBE()?

, , , float . f , writeDoubleBE.

+4

Source: https://habr.com/ru/post/1616701/