note 98001 added to function.bcscale

[email protected]
Newsgroups php.notes
Message-ID <[email protected]>
the function in the note below seems a bit more complicated then it really needs to be.  since we are dealing with strings, we can use the string functions instead.

<?php

  function DecimalClean($Input)
  {
      return (strpos($Input, '.') === false) ? $Input : rtrim($Input, '0');
  }

?>

Explanation:
First we check to see if the number contains a decimal point (we assume that it is a sane/valid number). 

If the number lacks a decimal point then we do not need to do anything, otherwise we use the trim function which is very fast because it is a low level function, to remove the zeros.  Trim will stop at the first character that is not a '0'.

The only limitation is that this version does not account for localized decimal points.
----
Server IP: 69.147.83.197
Probable Submitter: 174.21.219.64
----
Manual Page -- http://www.php.net/manual/en/function.bcscale.php
Edit        -- https://master.php.net/note/edit/98001
Del: integrated  -- https://master.php.net/note/delete/98001/integrated
Del: useless     -- https://master.php.net/note/delete/98001/useless
Del: bad code    -- https://master.php.net/note/delete/98001/bad+code
Del: spam        -- https://master.php.net/note/delete/98001/spam
Del: non-english -- https://master.php.net/note/delete/98001/non-english
Del: in docs     -- https://master.php.net/note/delete/98001/in+docs
Del: other reasons-- https://master.php.net/note/delete/98001
Reject      -- https://master.php.net/note/reject/98001
Search      -- https://master.php.net/manage/user-notes.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.