# Thread: Boolean: different two type of declare

1. Member
Join Date
Nov 2011
Posts
27
Rep Power
0

## Boolean: different two type of declare

I have 2 examples, I don't know what java really acts:
Java Code:
```boolean x = 4.45f==4.45;
boolean y=4.44f==4.44;```
Java will turn that (x=true) and (y=false). So, please tell me what java do in 2 above statements, please.

thanks :)

2. ## Re: Boolean: different two type of declare

Those boolean results imply that the float and double representations for 4.45 are identical while a float value 4.44 cast to type double differs from a double type value 4.45. Read this article.

kind regards,

Jos

3. Member
Join Date
Nov 2011
Posts
27
Rep Power
0

## Re: Boolean: different two type of declare

@: JosAH, thank for your kindly help. But can you tell me more shortly, please. I think this problem come from what java work. Because in C/C++, above code will output false for two case, too :D
@:I don't like your document you give to me, not because it's long, or not because it's hard. I don't like it because: It's long, and many part of this document seem easy to me (maybe because It belongs to math, and I love it). So, I hard to find what I need :(

thanks :)

4. Senior Member
Join Date
Jun 2008
Posts
2,568
Rep Power
15

## Re: Boolean: different two type of declare

He did tell you, it has to do with java's float and double representations. Read that document, completely, and you will understand.

5. Member
Join Date
Nov 2011
Posts
27
Rep Power
0

## Re: Boolean: different two type of declare

He did tell you, it has to do with java's float and double representations. Read that document, completely, and you will understand.
Oh, so thank for your help :P

6. Senior Member
Join Date
Jun 2008
Posts
2,568
Rep Power
15

## Re: Boolean: different two type of declare

I see no reason why we should repeat (with less accuracy and detail) what is already contained in the document (that you have). Just read it.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•