Janakiram Reddy
Janakiram Reddy

Reputation: 115

why the float is always 32 bit?

when my friends asked me the question why the integer size is changing from architecture to architecture? I told my friends like integer is replaced with an instruction of assembly i.e.MOVW (move the word) the word size is 16 bits(in some companies) and 32 bits(in some other) so that's why is it changing from architecture to architecture.

Is the above explanation is correct? please tell me if i was wrong.

and another question is,

why the size float is always 32 bits regardless of architecture? is it handled by hardware?

Upvotes: 3

Views: 5745

Answers (3)

Patricia Shanahan
Patricia Shanahan

Reputation: 26185

The current level of agreement on floating point formats is a consequence of the IEEE 754 standard, as others have pointed out.

Before that standard became dominant, there was no such agreement. Specifically, the Cray XMP computers had a 64-bit floating point type as their single precision float.

Upvotes: 2

Markus Kull
Markus Kull

Reputation: 1479

Because the IEEE-754 standard describes 32bit and 64bit floating point numbers in full detail down to the last bit. I dont know wether the C definition mandates IEEE-754 (probably not), but surely any serious mathematical programmer expects IEEE-754.

The difference to int: int is defined as the most efficient number type (most times the size of a register). Some compilers seem to favor 32bit ints on 64bit machines due to backward compatibility. But floating point sizes were never subject to compatibility issues.

Upvotes: 3

Patrick Hofman
Patrick Hofman

Reputation: 156978

An integer can still be 32 bits on a 64 bit machine. It is depending on the compiler, rather than the machine mostly. The 'int pointer' size can be changed to 64 bits on 64 bits machines, since the memory address size is 64 bits. That means your 'argument' isn't valid.

A float is then still a float too: usually we say it is 32 bits, but everyone is free to deviate from it. I think this has to do with the processor architectural standards we commonly apply to.

Upvotes: 1

Related Questions