Jump to content


Photo

math function


  • Please log in to reply
2 replies to this topic

#1 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 11 October 2006 - 03:35 PM

I have create a maths funtion to convert a currency as folows

[<?php
            $number1 = $HTTP_SESSION_VARS["icJag"]->col("ItemSubTotal");
$number2 = $row_rsCurrency['Rate'];
            echo number_format ($number1 * $number2);
?>]

The problem I have is that say I have a price of £49.49 and * it by the rate say 1.23 it rounds up the figure and dispalys just £60 not £60.87 as it should, I have tried seaching for other maths functions

Thanks

#2 alpine

alpine
  • Members
  • PipPipPip
  • Advanced Member
  • 756 posts
  • LocationNorway

Posted 11 October 2006 - 04:19 PM

Study the manual - using number_format without any extra parameters returns number without any decimals.

If only one parameter is given, number will be formatted without decimals, but with a comma (",") between every group of thousands.


http://no.php.net/ma...mber-format.php

#3 fazzfarrell

fazzfarrell
  • Members
  • PipPipPip
  • Advanced Member
  • 154 posts

Posted 13 October 2006 - 03:55 PM

Great thanks worked a treat!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users