Dixon Steel
Dixon Steel

Reputation: 1061

Float32 and UInt32?

I am looking at some older Apple code for C++, I am familiar with float but not Float32 and Uint32 types are they the same as standard float and ints?

Thanks

Upvotes: 6

Views: 23114

Answers (3)

Matt Ball
Matt Ball

Reputation: 359816

UInt32 is a 32-bit (4-byte) unsigned integer. This means that it can represent values in the range
[0, 2^32-1] (= [0, 4294967295]).

Float32 is a 32-bit (aka single-precision [contrast with double-precision]) floating point number.


As other answers have mentioned, the types exist to guarantee the width.

Upvotes: 9

Matteo Italia
Matteo Italia

Reputation: 126787

I suppose they are some typedef respectively for a floating point type and an unsigned integer type guaranteed to be 32 bit wide.

On most platforms they will simply decay to float (at least, on any machine that uses the IEEE 754 standard) and, on 32 bit machines, to unsigned int (on some 64 bit platforms it may decay to unsigned short).

Upvotes: 0

Puppy
Puppy

Reputation: 146910

The suffix gives the bit size. This makes them the same if and only if the Standard float and int have the same size on the target machine. They exist to give guaranteed sizes on all platforms.

Upvotes: 2

Related Questions