GUIpsp
GUIpsp

Reputation: 161

Are there fixed-width float types in clang?

GCC provides _Float32 and _Float64 for fixed-width floats.

However, these are not standard, and don't exist in clang. I also can't find the equivalents for clang.

Some platforms can define float or double to not be 32 or 64 bits, so using these types is not an option.

Upvotes: 4

Views: 1501

Answers (2)

R.. GitHub STOP HELPING ICE
R.. GitHub STOP HELPING ICE

Reputation: 215287

Yes. They're called float and double.

Upvotes: -3

John Bollinger
John Bollinger

Reputation: 180351

Answering the question as posed, CLang's documented language extensions do not include analogs of GCC's _Float32 and _Float64 types. Do note, however, that even GCC provides those only on targets that support corresponding types natively.

On the other hand, inasmuch as clang is built on top of LLVM, it is worthwhile to consider LLVM's documentation of FP type representations:

The binary format of half, float, double, and fp128 correspond to the IEEE-754-2008 specifications for binary16, binary32, binary64, and binary128 respectively.

In that sense, then, CLang's equivalents of _Float64 and _Float32 are double and float, respectively. (Indeed, the same equivalence holds in GCC for substantially all targets where the explicit-width versions are supported.)

Upvotes: 3

Related Questions