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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:12:54+00:00 2026-05-26T23:12:54+00:00

I have this code: partialProg = 100 * ((i+1) / len); Log.i(null, 100 *

  • 0

I have this code:

partialProg = 100 * ((i+1) / len);
Log.i(null, "100 * (" + (i+1) + "/" + len + ")" );
Log.i(null, "" + (int) partialProg + " <- int cast    original double -> " + partialProg);

where partialProg is a double, initialized to 1.0 as a global variable. partialProg is used to compute the progress in a lengthy upload process (len being the amount of data points to upload, and i being the current data point the loop is at). Logically, this is correct.

However, my ProgressDialog always displays 0%, until the final iteration, in which is displays 100%.

Curious, I used Log messages to try to find the problem. I get results like this:

11-22 13:21:47.714: ERROR/(3110): LOOP ENTERED: 1 accelX to check for null: -2.329
11-22 13:21:48.044: DEBUG/rapi(3110): Successful request
11-22 13:21:48.044: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:48.064: INFO/(3110): 100 * (2/20)
11-22 13:21:48.074: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:48.104: ERROR/(3110): LOOP ENTERED: 2 accelX to check for null: -10.924
11-22 13:21:48.434: DEBUG/rapi(3110): Successful request
11-22 13:21:48.434: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:48.454: INFO/(3110): 100 * (3/20)
11-22 13:21:48.454: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:48.484: ERROR/(3110): LOOP ENTERED: 3 accelX to check for null: -8.281
11-22 13:21:48.664: DEBUG/rapi(3110): Successful request
11-22 13:21:48.674: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:48.694: INFO/(3110): 100 * (4/20)
11-22 13:21:48.694: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:48.754: ERROR/(3110): LOOP ENTERED: 4 accelX to check for null: -2.438
11-22 13:21:49.334: DEBUG/rapi(3110): Successful request
11-22 13:21:49.334: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:49.334: INFO/(3110): 100 * (5/20)
11-22 13:21:49.334: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:49.364: ERROR/(3110): LOOP ENTERED: 5 accelX to check for null: -9.657
11-22 13:21:49.554: DEBUG/rapi(3110): Successful request
11-22 13:21:49.554: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:49.554: INFO/(3110): 100 * (6/20)
11-22 13:21:49.554: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:49.584: ERROR/(3110): LOOP ENTERED: 6 accelX to check for null: 7.042
11-22 13:21:49.653: DEBUG/rapi(3110): Successful request
11-22 13:21:49.653: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:49.653: INFO/(3110): 100 * (7/20)
11-22 13:21:49.653: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:49.694: ERROR/(3110): LOOP ENTERED: 7 accelX to check for null: -6.347
11-22 13:21:49.814: DEBUG/rapi(3110): Successful request
11-22 13:21:49.814: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:49.814: INFO/(3110): 100 * (8/20)
11-22 13:21:49.824: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:49.844: ERROR/(3110): LOOP ENTERED: 8 accelX to check for null: -15.663
11-22 13:21:49.973: DEBUG/rapi(3110): Successful request
11-22 13:21:49.973: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:49.973: INFO/(3110): 100 * (9/20)
11-22 13:21:49.973: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:50.013: ERROR/(3110): LOOP ENTERED: 9 accelX to check for null: -1.771
11-22 13:21:50.143: DEBUG/rapi(3110): Successful request
11-22 13:21:50.143: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:50.143: INFO/(3110): 100 * (10/20)
11-22 13:21:50.154: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:50.174: ERROR/(3110): LOOP ENTERED: 10 accelX to check for null: 12.326
11-22 13:21:50.304: DEBUG/rapi(3110): Successful request
11-22 13:21:50.304: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:50.304: INFO/(3110): 100 * (11/20)
11-22 13:21:50.304: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:50.324: ERROR/(3110): LOOP ENTERED: 11 accelX to check for null: -1.553
11-22 13:21:50.434: DEBUG/rapi(3110): Successful request
11-22 13:21:50.434: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:50.444: INFO/(3110): 100 * (12/20)
11-22 13:21:50.444: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:50.474: ERROR/(3110): LOOP ENTERED: 12 accelX to check for null: 3.895
11-22 13:21:50.584: DEBUG/dalvikvm(3110): GC_FOR_MALLOC freed 7642 objects / 590016 bytes in 95ms
11-22 13:21:50.684: DEBUG/rapi(3110): Successful request
11-22 13:21:50.684: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:50.694: INFO/(3110): 100 * (13/20)
11-22 13:21:50.694: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:50.704: ERROR/(3110): LOOP ENTERED: 13 accelX to check for null: 3.895
11-22 13:21:50.814: DEBUG/rapi(3110): Successful request
11-22 13:21:50.814: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:50.824: INFO/(3110): 100 * (14/20)
11-22 13:21:50.824: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:50.844: ERROR/(3110): LOOP ENTERED: 14 accelX to check for null: 6.320
11-22 13:21:51.033: DEBUG/rapi(3110): Successful request
11-22 13:21:51.033: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:51.033: INFO/(3110): 100 * (15/20)
11-22 13:21:51.033: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:51.064: ERROR/(3110): LOOP ENTERED: 15 accelX to check for null: -3.868
11-22 13:21:51.164: DEBUG/rapi(3110): Successful request
11-22 13:21:51.164: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:51.164: INFO/(3110): 100 * (16/20)
11-22 13:21:51.164: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:51.194: ERROR/(3110): LOOP ENTERED: 16 accelX to check for null: -9.820
11-22 13:21:51.304: DEBUG/rapi(3110): Successful request
11-22 13:21:51.304: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:51.314: INFO/(3110): 100 * (17/20)
11-22 13:21:51.314: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:51.324: ERROR/(3110): LOOP ENTERED: 17 accelX to check for null: -5.530
11-22 13:21:51.454: DEBUG/rapi(3110): Successful request
11-22 13:21:51.454: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:51.464: INFO/(3110): 100 * (18/20)
11-22 13:21:51.464: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:51.474: ERROR/(3110): LOOP ENTERED: 18 accelX to check for null: -2.601
11-22 13:21:51.583: DEBUG/rapi(3110): Successful request
11-22 13:21:51.583: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:51.583: INFO/(3110): 100 * (19/20)
11-22 13:21:51.594: INFO/(3110): 0 <- int cast    original double -> 0.0
11-22 13:21:51.614: ERROR/(3110): LOOP ENTERED: 19 accelX to check for null: -6.020
11-22 13:21:52.043: DEBUG/dalvikvm(767): GC_EXPLICIT freed 347 objects / 19880 bytes in 129ms
11-22 13:21:52.054: DEBUG/rapi(3110): Successful request
11-22 13:21:52.054: INFO/global(3110): Default buffer size used in BufferedReader constructor. It would be better to be explicit if an 8k-char buffer is required.
11-22 13:21:52.054: INFO/(3110): 100 * (20/20)
11-22 13:21:52.054: INFO/(3110): 100 <- int cast    original double -> 100.0
11-22 13:21:52.354: WARN/IInputConnectionWrapper(3110): finishComposingText on inactive InputConnection

You can see that it says that partialProg is always 0, which I assume is because it is multiplying some decimal number < 1 by 100. But, it’s of type double! Why would it be doing that?
I even tried typecasting it in a lot of places to a double – with no different results.

Any ideas of what’s going on here?

  • 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-26T23:12:54+00:00Added an answer on May 26, 2026 at 11:12 pm

    It doesn’t matter how you initialize partialProg, since you immediately overwrite it.

    What matters is the type of the expression 100 * ((i+1) / len);, which is an integer in your case (assuming i and len are integers). Consequently, the value of the expression is constrained to integral values.

    To make an expression of type double, just make the individial terms into doubles. For example:

    100.0 * double(i + 1) / double(len);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code #include <iostream> using namespace std; int main(int argc,char **argv) {
I have this code if(ereg(^(https),$url)) curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false); // execute, and log the result to curl_put.log
I have this code guile> (cairo-pdf-surface-create foo.pdf 100.0 100.0) ; and get this error
I have this code: dojo.declare(City, null, { constructor : function(cityid, cityinfo){ } }); dojo.declare(TPolyline,
i have this code which doesnt work: void CAnalyzerIF::SetData(int i_iIters, const CParameterSet* i_CParameterSet) {
I have this code: public void replay() { long previous = DateTime.Now.Ticks; for (int
I have this code, int main() { std::string st; std::stringstream ss; ss<<hej hej med
I have this code in my controller for Index view.. public ActionResult Index(int? id)
I have this code: <ComboBox Width=100 ItemsSource={Binding FontList} x:Name=fontComboFast> <ComboBox.ItemsPanel> <ItemsPanelTemplate> <VirtualizingStackPanel /> </ItemsPanelTemplate>
I have this code in jQuery, that I want to reimplement with the prototype

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.