PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, August 10, 2022

[FIXED] How to truncate a number

 August 10, 2022     decimal, html, numbers, perl, truncate     No comments   

Issue

I should display numbers to a table. But I need The number has only two characters after a comma. How to do it correctly.

            $score =  $schet;
%>
            <tr class="ten" >
                <td class="six" > <%= $schet %></td>
                <td> <%= $d->start %></td>
                <td> <%= $d->end   %></td>
            </tr>
<%
        }

Solution

Use sprintf:

my $number_with_two_decimal_places = sprintf '%.2f', $float;


Answered By - choroba
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing