473,441 Members | 1,469 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

How do I get this result in the following expressions?

108 100+
I just implemented the following script with regerence to the internet and got as result 20...


long val=10;

long g=(byte)(val << 1);
System.out.println(g);

I am unable to understand this expression and how the result has been calculated..
I would be grateful if some1 could help me wd this...


Thanks in advance
Jul 6 '10 #1

✓ answered by Dheeraj Joshi

Simple
In binary 10 is represented as 1010. Now shift this to left once. It now becomes 10100. Which is equivalent of 20 in decimal.

Appending at the LSB depend on sign extensions.

Regards
Dheeraj Joshi

1 1095
Dheeraj Joshi
1,123 Expert 1GB
Simple
In binary 10 is represented as 1010. Now shift this to left once. It now becomes 10100. Which is equivalent of 20 in decimal.

Appending at the LSB depend on sign extensions.

Regards
Dheeraj Joshi
Jul 7 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

47
by: Andrey Tatarinov | last post by:
Hi. It would be great to be able to reverse usage/definition parts in haskell-way with "where" keyword. Since Python 3 would miss lambda, that would be extremly useful for creating readable...
7
by: Yannick Turgeon | last post by:
Hello all, I tryed to simplify the problem as much as possible. I'll start with the DDL: ---------------------------------- CREATE TABLE #MyTable( NoID INT, Type CHAR,...
3
by: Amir Parsa | last post by:
655.5555-655 =0.555500000000052 (655.55-655)*100 =54.9999999999955 Visual C# 2003
11
by: Martin Robins | last post by:
I am trying to parse a string that is similar in form to an OLEDB connection string using regular expressions; in principle it is working, but certain character combinations in the string being...
2
by: Dylan | last post by:
thanks for any comments. Here's the code //------------------------------------------------------------------ #include <iostream> class Base { protected: virtual int GetValue()=0;
10
by: hclugano | last post by:
Hi! There is a SQL Create Table statement, for example: CREATE TABLE . ( IDENTITY (1, 1) NOT NULL, NOT NULL, ( 15) NOT NULL ..... ) ON
0
by: Anthony | last post by:
Hi there, i am trying to perform url rewriting using regular expressions and am after a little performance advice as regular expressions just baffle me: Basically my site has only one style...
4
by: choudharymv | last post by:
I have 1 table "Progress" P_no b_no status build_date ---------------------------------------------------------------- 25 1 First_slab ...
0
by: Ron | last post by:
Ron wrote: I'm sure we can help you, but we'll need more info. How are the different Fields of your Text File separated - Commas, Spaces or other characters? Is the Part Number always at the...
41
by: dspfun | last post by:
Hi! Are suffixes allowed on expressions? For example, is the following allowed: #define SECONDS_PER_YEAR (60 * 60 * 365) UL I found this in a C test at...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.