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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T11:27:43+00:00 2026-05-26T11:27:43+00:00

When 10000-100, then result should be 9900. I tried when I use:- < ?php

  • 0

When 10000-100, then result should be 9900.

I tried when I use:-

< ?php

$num1 = number_format(round(10000,1),2);
$num2 = number_format(round(100,1),2);
echo $num1 - $num2;

?>

The above result is -90, that made me realize that the number_format function is not applicable in calculations.

Would there be any way that I can convert a value of number_format (obtained from POST from a previous page) back to numerical value for normal calculation?

  • 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-26T11:27:44+00:00Added an answer on May 26, 2026 at 11:27 am

    To start, the reason is that:

    (int) "10,000.00"
    

    resolves to 10 since it stops parsing at the first non-numeric character. Thanks to PHP’s weird type system, this is done implicitly when you subtract the strings.

    Yes, you can strip out the commas easily:

    $unformatted = str_replace(",", "", $formatted);
    

    but it’s cleaner to just post the raw numeric value (you can still use number_format for the displayed value).

    EDIT: It is good practice to explicitly convert numeric strings (without commas) to float (or int) with either a cast ((int) or (float)) or the function version (intval or floatval).

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

Sidebar

Related Questions

I have 1000 rows of data but need to only display 100 rows at
The code below is extremely slow for tables of any significant size. (100, 1000,
Code I: for(i=0; i<100; i++){ for(j=0; j<1000; j++){ x = y; } } Code
I want to print the first 10000 prime numbers. Can anyone give me the
I have an application that generates around 10000 printed pages per month. Each report
I have a set of 10000 files. In all of them, the second line,
I have a ListView which sometimes I need to put around 10000 items in.
How can I store and retrieve the number 2**10000 in a binary file in
I am using setInterval(fname, 10000); to call a function every 10 seconds in JavaScript.
I often need relatively small (<10000 entries <1kb) caches for speeding up calculations. My

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.