7 Replies - 869 Views - Last Post: 08 June 2010 - 07:11 AM Rate Topic: -----

#1 kitsu   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-February 09

number help

Posted 04 June 2010 - 09:45 PM

Hello dreamincode!

I actually need help on php

This is the situation of a page I want to generate:
I want this value:
$val=3.4887
$val2=7305.1

became to this:
$val=3.49
$val2=0.73


and another situation is
I want $val to have a a value closer to divisible by 5
example:
This value
$val=3.49
$val2=0.73

wil turn to this because 3.49 is much closer to 3.50 than 3.45
$val=3.50
$val2=0.75


I will use this for a computation I'm making

Can anyone give me a code for this?
I dont know how will I search this on the net so I thought I should ask it here ^^

Is This A Good Question/Topic? 0
  • +

Replies To: number help

#2 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3800
  • View blog
  • Posts: 13,785
  • Joined: 08-August 08

Re: number help

Posted 04 June 2010 - 10:02 PM

http://php.net/manua...ction.round.php
Was This Post Helpful? 2
  • +
  • -

#3 kitsu   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-February 09

Re: number help

Posted 05 June 2010 - 11:50 PM

@CTphpnwb - Thanks for the manual :)

but I still dont know what to use for the second situation -_-
Was This Post Helpful? 0
  • +
  • -

#4 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3800
  • View blog
  • Posts: 13,785
  • Joined: 08-August 08

Re: number help

Posted 06 June 2010 - 03:28 AM

$rounded = 5* round($val/5,2);
Was This Post Helpful? 3
  • +
  • -

#5 kitsu   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-February 09

Re: number help

Posted 07 June 2010 - 04:33 AM

^ Thank you so much for the code ^.^
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12355
  • View blog
  • Posts: 45,464
  • Joined: 27-December 08

Re: number help

Posted 07 June 2010 - 08:01 AM

@kitsu: I also wanted to point out rule #1, which states that we don't do homework or give out code. So in the future, if you show us your good faith efforts and specifically describe the problems or errors with your code, we will be happy to help you. :)
Was This Post Helpful? 1
  • +
  • -

#7 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3800
  • View blog
  • Posts: 13,785
  • Joined: 08-August 08

Re: number help

Posted 07 June 2010 - 08:37 AM

View Postmacosxnerd101, on 07 June 2010 - 10:01 AM, said:

@kitsu: I also wanted to point out rule #1, which states that we don't do homework or give out code. So in the future, if you show us your good faith efforts and specifically describe the problems or errors with your code, we will be happy to help you. :)

I agree, and was a little leery about providing an answer. In this case though, it seemed to be more a matter of not understanding the math than making the effort to code, so despite my misgivings I answered.
Was This Post Helpful? 0
  • +
  • -

#8 kitsu   User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 23
  • Joined: 26-February 09

Re: number help

Posted 08 June 2010 - 07:11 AM

View Postmacosxnerd101, on 07 June 2010 - 07:01 AM, said:

@kitsu: I also wanted to point out rule #1, which states that we don't do homework or give out code. So in the future, if you show us your good faith efforts and specifically describe the problems or errors with your code, we will be happy to help you. :)

oh sorry bout that
I actually have my code but dont know the math for my problem
Thanks for reminding me! ^_^
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1