Jump to content

  • Log In with Google      Sign In   
  • Create Account

How many bytes is float?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
12 replies to this topic

#1 The C modest god   Banned   -  Reputation: 100

Like
Likes
Like

Posted 15 February 2004 - 02:09 AM

?

Sponsor:

#2 billybob   Members   -  Reputation: 134

Like
Likes
Like

Posted 15 February 2004 - 02:18 AM

sizeof(float)

#3 TangentZ   Members   -  Reputation: 388

Like
Likes
Like

Posted 15 February 2004 - 02:24 AM

Usually 32 bits (4 bytes).

When in doubt, check sizeof(float).



Kami no Itte ga ore ni zettai naru!

#4 Blue Phoenix   Members   -  Reputation: 122

Like
Likes
Like

Posted 15 February 2004 - 02:24 AM

It dependends on the precision.

It can be 16-bit (float) or 32-bit (double). Anyone correct me if i''m wrong.

#5 jpab   Members   -  Reputation: 881

Like
Likes
Like

Posted 15 February 2004 - 02:44 AM

quote:
Original post by Blue Phoenix
It dependends on the precision.

It can be 16-bit (float) or 32-bit (double). Anyone correct me if i''m wrong.

As others have said, the only definitive answer is sizeof(float). But I believe that it''s often 32-bit for float, and 64-bit for double.

John B

#6 Jingo   Members   -  Reputation: 582

Like
Likes
Like

Posted 15 February 2004 - 02:57 AM

sizeof() only gives you the size of the object in terms of char, sizeof(char) is always one. You should check
std::numeric_limits<char>::digits  
to work out the number of bits in a char

[edited by - Jingo on February 15, 2004 9:58:28 AM]

#7 Cedric   Members   -  Reputation: 158

Like
Likes
Like

Posted 15 February 2004 - 03:05 AM

DUDE! You have 6 questions shown on the page of this forum RIGHT NOW, and 4/6 could have been easily answered by a forum search, or by using Google Groups! And 1 of the remaining two was a problem whose solution you found yourself (one has to wonder if you had really tried enough before posting).

The sum of the views for those 6 questions is 448! That''s a lot of time spent on reading trivial questions.

Final advice: read the C++ FAQ Lite. It''s a good investment.

Cédric

#8 antareus   Members   -  Reputation: 576

Like
Likes
Like

Posted 15 February 2004 - 05:48 AM

quote:
Original post by Cedric
DUDE! You have 6 questions shown on the page of this forum RIGHT NOW, and 4/6 could have been easily answered by a forum search, or by using Google Groups! And 1 of the remaining two was a problem whose solution you found yourself (one has to wonder if you had really tried enough before posting).

The sum of the views for those 6 questions is 448! That''s a lot of time spent on reading trivial questions.

Final advice: read the C++ FAQ Lite. It''s a good investment.

Cédric

You sound like me.


#9 SabreMan   Members   -  Reputation: 504

Like
Likes
Like

Posted 16 February 2004 - 12:47 AM

quote:
Original post by The C modest god
?

Do we have twenty questions to guess which language and platform you''re using?


#10 superdeveloper   Members   -  Reputation: 188

Like
Likes
Like

Posted 16 February 2004 - 06:54 AM

Be careful all: in java, a char is 2 bytes.

Java of course has a "byte" keyword to represent the 8 bit entity. Java focuses on (unicode, etc) 16 bit versions of characters, "chars"...

But yes, in C/C++, a byte is 8 bits wide.


#11 Jingo   Members   -  Reputation: 582

Like
Likes
Like

Posted 16 February 2004 - 07:25 AM

quote:
Original post by superdeveloper
But yes, in C/C++, a byte is 8 bits wide.



No, the number of bits in a C++ byte is undefined.



#12 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 16 February 2004 - 07:56 AM

quote:
Original post by Jingo
No, the number of bits in a C++ byte is undefined.
You mean the number of bits in a C++ char? Because byte is defined to be 8 bits, much like nibble is defined as 4 bits, independ of the platform or the language.

#13 Josh Petrie   Moderators   -  Reputation: 3116

Like
Likes
Like

Posted 16 February 2004 - 08:12 AM

quote:

You mean the number of bits in a C++ char? Because byte is defined to be 8 bits, much like nibble is defined as 4 bits, independ of the platform or the language.



In C++ a char is defined to be one byte. A byte is not neccessarily 8-bits, although for all intents and purposes you are probably safe assuming that nowadays. Likewise, a nybble is defined to be half a byte, not neccessarily four bits.

In any case, I think we''re all agreed that the answer to the OP is sizeof(float), at least in C++.

(I don''t really know if there is an "official" definations for byte, nybble, et cetera, so I''m basically going off of foldoc.org''s entries for the same).




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS