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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:51:03+00:00 2026-05-10T19:51:03+00:00

Is there any library function for this purpose, so I don’t do it by

  • 0

Is there any library function for this purpose, so I don’t do it by hand and risk ending in TDWTF?

echo ceil(31497230840470473074370324734723042.6);  // Expected result 31497230840470473074370324734723043  // Prints <garbage> 
  • 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. 2026-05-10T19:51:04+00:00Added an answer on May 10, 2026 at 7:51 pm

    This will work for you:

    $x = '31497230840470473074370324734723042.9';  bcscale(100); var_dump(bcFloor($x)); var_dump(bcCeil($x)); var_dump(bcRound($x));  function bcFloor($x) {     $result = bcmul($x, '1', 0);     if ((bccomp($result, '0', 0) == -1) && bccomp($x, $result, 1))         $result = bcsub($result, 1, 0);      return $result; }  function bcCeil($x) {     $floor = bcFloor($x);     return bcadd($floor, ceil(bcsub($x, $floor)), 0); }  function bcRound($x) {     $floor = bcFloor($x);     return bcadd($floor, round(bcsub($x, $floor)), 0); } 

    Basically it finds the flooy by multiplying by one with zero precision.

    Then it can do ceil / round by subtracting that from the total, calling the built in functions, then adding the result back on

    Edit: fixed for -ve numbers

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

Sidebar

Ask A Question

Stats

  • Questions 80k
  • Answers 80k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Check out this article on MSDN: .NET Remoting: Writing an… May 11, 2026 at 4:16 pm
  • Editorial Team
    Editorial Team added an answer Does one of the subdomains use an underscore? IE has… May 11, 2026 at 4:16 pm
  • Editorial Team
    Editorial Team added an answer Assuming you don't need result outside of the loop, you… May 11, 2026 at 4:16 pm

Related Questions

Is there any library function for this purpose, so I don't do it by
The company I work for has a large webapp written in C++ as an
What are some good tools for getting a quick start for parsing and analyzing
Is there any way to redefine a class or some of its methods without
The documentation for the round() function states that you pass it a number, and

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.