Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

ANDing Shorts

Posted on 2005-03-01
7
Medium Priority
?
212 Views
Last Modified: 2010-03-31
Please help - very frustrated

The following code:


      short test1;
      short test2;
      short test3;

      test1 = 0x34;
      test2 = 0x00ff;
      test3 = test1&test2;

Produces the following error:

test.java:383: possible loss of precision
found   : int
required: short
        test3 = test1&test2;
                     ^
1 error



0
Comment
Question by:Moskaluke
  • 5
  • 2
7 Comments
 
LVL 37

Expert Comment

by:zzynx
ID: 13433834
Does
  test3 = (short) (test1&test2);
help?
0
 

Author Comment

by:Moskaluke
ID: 13433862
Nope - Same error.  Thanks for getting back quick.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13433871
>> Nope - Same error.
Well, I reproduced the exact error message.
But by adding that casting it has gone.
Sure you have that right?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 37

Expert Comment

by:zzynx
ID: 13433875
Did you put (test1&test2) between brackets?
0
 
LVL 37

Accepted Solution

by:
zzynx earned 500 total points
ID: 13433880
>> Did you put (test1&test2) between brackets?
I think you didn't.
If you didn't, you just cast test1 to short (which it is already)
0
 

Author Comment

by:Moskaluke
ID: 13433916
Sorry -
Yes - I missed the braces around test1&test2

Thank you very much.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 13433937
>> Thank you very much.
You're welcome

Thanks for accepting
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question