Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6641667
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:50:15+00:00 2026-05-25T23:50:15+00:00

BHere’s the code: c# private void button1_Click(object sender, EventArgs e) { int a =

  • 0

BHere’s the code:

c#

private void button1_Click(object sender, EventArgs e)
{
  int a = -33554432;
  byte b = (byte)(a >> 24);
  MessageBox.Show(b.ToString());
}

java

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    int a = -33554432;
    byte b = (byte)(a >> 24);
    JOptionPane.showMessageDialog(null, Byte.toString(b));
}

I’ve read around this problem, and I believe there is a relatively simple way of understanding the different behavior, but I need a little help in reaching this understanding. Any takers, please?

Many thanks!

EDIT: ok, now using Byte.toString(). Output for c# = 254 java = -2

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T23:50:16+00:00Added an answer on May 25, 2026 at 11:50 pm

    Byte in Java is a signed value. In this case you could actually just use:

    // Note the triple >
    int b = a >>> 24;
    

    Alternatively:

    byte b = (byte) (a >> 24);
    int c = b & 0xff;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Which two code fragments correctly create and initialize a static array of int elements?
Let's say that I have two classes A and B. class A { private:
Anyone know what the problem with this code is? let rec Foo(a,b) = match
Given the following: class BC { public void Display() { System.Console.WriteLine(BC::Display); } } class
Consider the following situation: [Export] class A { } class B { [Import] private
Common examples for a ObjC object are like this (for the header file): @interface
so I have array like ParamsArray {a,b,a,a,...b} (so i have 2 kinds of parameters
I have a C# .NET 2.0 project A (class library) that has a form
i am working on a project of online resume management system and i am
I have a text file that has sets of text I need to extract

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.