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 8215653
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:51:25+00:00 2026-06-07T11:51:25+00:00

public static int NUM_FRAMES = 8; public static int FRAME_REPEAT_NO = 2; int height

  • 0
public static int NUM_FRAMES = 8;
public static int FRAME_REPEAT_NO = 2;
int height = 24;
//bitmap.getWidth() is 168 and bitmap.getHeight() is 91

double w = bitmap.getWidth();
w = w/NUM_FRAMES;
w = w*FRAME_REPEAT_NO;
w = w*height;
w = w/bitmap.getHeight();

I do this and i get the value of w as 11.07 which is correct.

But when i do this:

double w  = FRAME_REPEAT_NO*(bitmap.getWidth()/NUM_FRAMES)*(height/bitmap.getHeight());

value of w is always 0;

Can someone explain to me why this is happening?

P.S. I’m doing it in an android app…

  • 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-07T11:51:27+00:00Added an answer on June 7, 2026 at 11:51 am

    Others have already addressed your question, so I won’t repeat their answers, but one suggestion I’ll make. Consider computing your result using

    w = (double)(FRAME_REPEAT_NO * bitmap.getWidth() * height) / (double)(NUM_FRAMES * bitmap.getHeight())

    This allows you to live in the predictable land of integers until the very end where you do the division. So any error in the result comes from a single operation instead of aggregating multiple errors. And if for whatever reason you decided you wanted to get an integer result, you can drop the doubles and still get 11 as the answer.

    Not a big deal but just thought I’d put it out there.

    EDIT: I saw from your comment on another post that you actually want the 11. Good. So just drop the doubles altogether:

    w = (FRAME_REPEAT_NO * bitmap.getWidth() * height) / (NUM_FRAMES * bitmap.getHeight())

    Answer is exactly 11 (integer), which is different by the way than the floating point approximation of 11.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

say I have: class Test { public static int Hello = 5; } This
When i try to compile this: public static int compareCardhl (Card c1, Card c2)
I have this code: package picalculator; //import java.util.Scanner; public class PiCalculator { static int
So this probably would be easy if done like this public static [] nums(int
public static int AwaitingApprovals() { int numApprovals = 0; string sql = SELECT COUNT(Type)
public static int ABC(int x, int y) { if(y==0) return(1); else return(x * ABC(x,y-1));
First code : public static int pitagoras(int a, int b) { return (int) Math.sqrt(a*a
I have: public static int[] ArrayWorkings() I can call it happily with MyClass.ArrayWorkings() from
Code 1: public static int fibonacci (int n){ if (n == 0 || n
here's the method: public static int chooseStrat () { String[] strats = new String[1]

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.