Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hex literal syntax for literals in webassembly (wast)

Tags:

webassembly

Webassembly: I cannot find a reference for this syntax (f32.const -0x0p+0). What number / bit pattern does it represent? It is from a test file for the reference interpreter:

https://github.com/WebAssembly/spec/blob/master/test/core/f32.wast#L19

like image 415
Mauro Bringolf Avatar asked Nov 01 '25 04:11

Mauro Bringolf


2 Answers

It’s hexadecimal floating-point as supported by C and more recently C++.

The significand is given in hexadecimal, and the exponent is given in decimal and interpreted with respect to base 2. It can exactly represent all floating-point numbers except NaNs.

The text format adopted this in this issue.

like image 64
JF Bastien Avatar answered Nov 02 '25 17:11

JF Bastien


It is hexadecimal float notation, as inspired by C and other languages.

The respective specification can be found here.

like image 30
Andreas Rossberg Avatar answered Nov 02 '25 18:11

Andreas Rossberg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!