Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 long into a float
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
syntax_error




PostPosted: Wed Sep 26, 2007 12:30 pm   Post subject: long into a float

a genral question
as far as I know a long is 8 bits
and a float is 4 bits
then why in java you can automaticly cast a long into a float?
thx in advance
Syntax_Error
Sponsor
Sponsor
Sponsor
sponsor
StealthArcher




PostPosted: Wed Sep 26, 2007 12:34 pm   Post subject: Re: long into a float

I think you have those backwards.....

longs are 4 bytes if i remember correctly
HeavenAgain




PostPosted: Wed Sep 26, 2007 2:45 pm   Post subject: RE:long into a float

code:
data type   size (in bits)            range
byte             8                     -2^7 to 2^7 - 1
short            16                      -2^15 to 2^15 - 1
int                32                      -2^31 to 2^31 - 1
long              64                      -2^63 to 2^63 - 1


type        in bytes

float          32
double        64

a long is 64 bits
a byte IS 8 bits
and a float is 32 BYTES


more info is linked here
wtd




PostPosted: Wed Sep 26, 2007 5:14 pm   Post subject: Re: RE:long into a float

HeavenAgain @ Thu Sep 27, 2007 3:45 am wrote:
and a float is 32 BYTES


Ummmm...
Zampano




PostPosted: Wed Sep 26, 2007 6:55 pm   Post subject: Re: long into a float

How much memory would I need to take a byte out of a sundae double banana ice cream float?

*My own lameness is astounding.*
McKenzie




PostPosted: Wed Sep 26, 2007 7:30 pm   Post subject: Re: long into a float

I thought the automatic cast was to double? That aside, the reason for the automatic conversion is that long is a long integer, as soon as you have any fractional component to a number long can't hold it (e.g. 3.5)
Nick




PostPosted: Wed Sep 26, 2007 8:19 pm   Post subject: RE:long into a float

zampano ur bytes are so small it takes 4 to equal a nybble (AHAHAHAHA) [btw 4 bytes = a nybble]
rizzix




PostPosted: Wed Sep 26, 2007 9:46 pm   Post subject: RE:long into a float

Wow a lot of you are misusing the word byte for bit.

1 byte = 8 bits
1 nibble = 4 bits


Int's/floats are 32-bit or 4-byte. Long/doubles are 64-bit or 8-bytes.
Sponsor
Sponsor
Sponsor
sponsor
rdrake




PostPosted: Wed Sep 26, 2007 10:00 pm   Post subject: Re: RE:long into a float

rizzix @ Wed Sep 26, 2007 9:46 pm wrote:
Wow a lot of you are misusing the word byte for bit.

1 byte = 8 bits
1 nibble = 4 bits


Int's/floats are 32-bit or 4-byte. Long/doubles are 64-bit or 8-bytes.
Nah, some people like to be really precise with their numbers. 2^(32*8) is nothing!
syntax_error




PostPosted: Sat Sep 29, 2007 9:51 pm   Post subject: Re: long into a float

ahh my mistake I meant to write byte.. :$
but a long is 64 bytes nonetheless
and a float is 32 bytes
so how can you in the language java
automatically cast a long into a float?
zylum




PostPosted: Sun Sep 30, 2007 2:30 am   Post subject: Re: RE:long into a float

rizzix @ Wed Sep 26, 2007 10:46 pm wrote:
Wow a lot of you are misusing the word byte for bit.

1 byte = 8 bits
1 nibble = 4 bits


Int's/floats are 32-bit or 4-byte. Long/doubles are 64-bit or 8-bytes.
haskell




PostPosted: Sun Sep 30, 2007 8:05 am   Post subject: RE:long into a float

Grrrr...

http://members.aol.com/M206ou/m206/M206_Smalltalk_tutorial_ascii.htm

Read it, or I'll mock you till your cry toy your momma.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: