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

Our application stores records with shorter texts (strings of 100-1000 characters). It provides search
I have this situation: $(#button).toggle(function(){ $(#window).animate({top:'0%'},1000); },function(){ $(#window).animate({top:'-100%'},1000); }); but I need change it
I am trying to create a custom RegularExpressionValidator to validate the current expression number(0-99).number(100-1000)\number(0-99).number(100-1000)
how do I determine the positions in percentages? $(document).ready(function(){ $(#button).toggle(function(){ $(#slide).animate({top:-100%},1000); },function(){ $(#slide).animate({top:0%},1000); });
Is a 1000 users looking at 100 unique pages easier on the server than
I have 1000 rows of data but need to only display 100 rows at
using crystal report 7 ID Value total 001 100 2000 002 300 1000 003
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 have a list with these values: ['1', '10', '100.3', '1000.4', '1000.42', '150', '200',

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.