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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:42:11+00:00 2026-06-09T15:42:11+00:00

Here’s a C code; #include<stdio.h> #include<math.h> int main() { double n=10.0; double automatic =

  • 0

Here’s a C code;

#include<stdio.h>
#include<math.h>
int main()
{
    double n=10.0;
    double automatic = pow(10.0,log10(n)-log10(5.0));
    printf("%.9lf\n",log10(n)-log10(5.0));
    printf("%.9lf\n",pow(10.0,0.30102996));
    double manual = pow(10.0,0.30102996);
    printf("%.9lf %lf\n",automatic, floor(automatic));
    printf("%.9lf %lf\n",manual,floor(manual));
    return 0;
}

Output is:

0.301029996
1.999999836
2.000000000 1.000000
1.999999836 1.000000

From output I can infer that in pow(x,y) y is rounded off to 6 digits because it’s signature is as pow(double x, double y) so that 0.301029996 becomes 0.301030 and that’s why value of automatic is 2.000000000 otherwise it would be same as manual.

My questions:

  1. Is my inferation correct?
  2. If answer to first question is true then how can we bypass this rounding-off to achieve more accurate results?
  • 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-09T15:42:13+00:00Added an answer on June 9, 2026 at 3:42 pm

    pow does not round to 6 digits. It uses double precision, which for an IEEE double is 52 bits of significand (roughly 15 decimal places). It may or may not be accurate to the last digit at that precision, but it’s usually close.

    The exact value of the base-10 log of 2 is close to 0.301029995663981195213738894724 (source: Wolfram Alpha). It is an irrational number, and so cannot be exactly represented by any digit system (decimal or binary).

    Your results show that log10(n)-log10(5.0) has returned a value that’s closer to the exact mathematical base-10 log of 2, than 0.30102996 is. The reason you got 1.999999836 is that you manually made your value less accurate when you replaced it with 0.30102996. Which isn’t the rounded value, btw – count the 9s.

    Your call pow(10.0,log10(n)-log10(5.0)) has returned a result which is very slightly less than 2 (as show by the floor), but close enough that it rounds to 2 at 9 places. You are not going to get better than this using the double type.

    So I don’t really know what you mean by “avoid the rounding off”. If you don’t want to make the value less accurate, don’t manually round it to 9 places, and certainly don’t miss out any digits when you copy it 😉

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

Sidebar

Related Questions

Here is a code snippet I was working with: int *a; int p =
Here's my code in the <head></head> : <link rel=stylesheet href=http://code.jquery.com/mobile/1.1.0/jquery.mobile-1.1.0.min.css /> <script type=text/javascript src=http://code.jquery.com/jquery-1.7.1.min.js></script>
Here is the code in a function I'm trying to revise. This example works
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is my SQL script CREATE TABLE tracks( track_id int NOT NULL AUTO_INCREMENT, account_id
Here is an example: I write html code inside of textarea, then I swap
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here's a piece of code I copied from http://www.schillmania.com/content/projects/javascript-animation-1/demo/ Very simple JS animation: function
Here is the code I'm using inside my AsyncTask DefaultHttpClient httpClient = new DefaultHttpClient();
Here is my class: public class A{ private void doIt(int[] X, int[] Y){ //change

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.