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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:24:15+00:00 2026-06-12T01:24:15+00:00

I making one counter, I am using PHP and almost everything was going fine

  • 0

I making one counter, I am using PHP and almost everything was going fine but i found one small bug in it.

My first two step on counter is going fine that is $bid and $stax.

My last result $pay should be : 8138 + 814 + 448 = 9400 but it is giving me $9,399

My Output is:

Value $8,138 bid $814 tax $448 You Pay $9,399
Value $8,952 bid $895 tax $492 You Pay $10,339
Value $9,847 bid $985 tax $542 You Pay $11,373

Here is my php

<?php
$i = 0;
$v = 8138;  // value : 8138
do {
    $i++;
    $bid  = $v / 10;      // output : $814
    $ftax = $v + $bid;
    $stax = $ftax / 20;  // output : tax $448
    $pay  = $v + $bid + $stax;   // 8138 + 814 + 448 = 9400
    echo "Value $" . number_format($v) . " bid $" . number_format($bid) . " tax $" . number_format($stax) . " You Pay $" . number_format($pay) . "<br />";
    $v = $v * 1.1;
} while ($i <= 2);
?>

Thanks in advance 🙂

  • 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-12T01:24:16+00:00Added an answer on June 12, 2026 at 1:24 am

    Change your echo line to not drop decimals:

    echo "Value $" . $v . " bid $" . $bid . " tax $" . $stax . " You Pay $" . $pay . "<br />";
    

    Value $8138 bid $813.8 tax $447.59 You Pay $9399.39
    Value $8951.8 bid $895.18 tax $492.349 You Pay $10339.329
    Value $9846.98 bid $984.698 tax $541.5839 You Pay $11373.2619

    So 8138 + 813.8 + 447.59 = 9399.39, which rounds down to 9399.

    On the other hand, if you round immediately, 813.8 rounds up to 814 and 447.59 rounds up to 448, but you’ve just added 0.61 to your calculation before even starting, which obviously results in a higher number (9400).

    This is why math and science teachers tell you not to round until the very end, since each time you do it, your answer gets less accurate.

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

Sidebar

Related Questions

I was making one table that have two foreign key to another tables. But
I am making one dynamic library by using some function of libmxml.a library but
Why does changing/making errors in one's codebase sometimes destroy a session in Codeigniter/PHP? I
Iam making an app which has one index.php file. I also have these other
Hi guys i m making one asp.net project with silverlight2.0 .But i cannot get
Previous question was to encode two Int32 into one Int64 [ C# - Making
I am making one application where i am reading mails from Lotus Notes. I
I am making one security related application in android so i am looking for
I'm making one part in my app where if you push the button then
I ran into the situation where my class is making one asynchronous web call

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.