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

  • SEARCH
  • Home
  • 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 8701457
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:24:08+00:00 2026-06-13T02:24:08+00:00

I have one decimal value like 65 and I want to divide this value

  • 0

I have one decimal value like 65 and I want to divide this value in 2 raised to format.

For example, I have this type rule:

enter image description here

If I get 42 as a decimal number, I want to divide first 42 number in format of 2 raised to. Then, I want to output its power only, like:

OutPut : 1,3,5

enter image description here

For example, if I have 65 as a decimal number, then I want 6,0 as its output, because (2 raised to 6) + (2 raised to 0) = 65.

Thanks

Anybody can help me how I can achieve this thing in Java.

  • 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-06-13T02:24:09+00:00Added an answer on June 13, 2026 at 2:24 am

    You can repeatedly compare the least significant bit, counting as you go, and right-shifting the number to look at each bit in turn:

    int n = 65
    int d = 0;
    while (n > 0) {
        if ((n & 1) == 1) {  // check LSB
            System.out.println(d);
        }
        n >>>= 1;  // shift right
        ++d;       // inc digit count
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been successful at rounding my value to one decimal point, but I
I have this in one of my queries: FORMAT(ROUND(AVG(`rating` * 2)) / 2, 1)
I have two decimal datatype columns; I want them displayed like so: Column 1
I have a float value, that I would like to show it in format
Here I have one file testdec.txt . In this File Contents are like below.
I have the following column specified in a database: decimal(5,2) How does one interpret
have one time consuming step that flattens a bunch of files. basically i'd like
I have a simple GridView ; something like this for a regular Item or
I have a 32-bit integer value and I want to translate that into two
When a user goes to edit a number, I want to format a number

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.