Author |
Message |
syntax_error
|
Posted: 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
|
|
|
StealthArcher
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
|
|
rdrake
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
|
|
|
|
|