SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2003
    Location
    Montgomery, TX
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with float field

    I have a mySQL table with pitcher stats. The innings pitched field is a float, because a pitcher can pitch partial innings, such as 3 1/3, which is stored as 3.1. When I am adding a pitchers innings pitched, I need to be able to tell when it the number after the decimal gets to 3 or greater, to increment the number before the decimal, so if they pitched 10.3, that should be 11, or if they pitched 10.4, that should be 11.1. How can I do this?

    Thanks,

    David

  2. #2
    WebAmoeba mythix's Avatar
    Join Date
    Aug 2002
    Location
    here
    Posts
    578
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hmmm, can't think of a mathematical way. Except for using 'base 3', somehow???

    Wouldn't be to hard to hard to code.

    if number = x.3
    number + 0.7

    something along those lines?
    Laws are like sausages. You have much more respect for them if you haven't actually seen how they're made.

    http://www.webamoeba.co.uk

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is MySQL, not PHP. Moved...
    Aaron Brazell
    Technosailor



  4. #4
    Sidewalking anode's Avatar
    Join Date
    Mar 2001
    Location
    Philadelphia, US
    Posts
    2,205
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Store it in the database as thirds of innings.

    DB:
    Code:
    innings
    --------
    10
    33
    PHP Code:
    $result mysql_query('SELECT innings FROM table');
    while(
    $row mysql_fetch_row($result)) {
      
    $thirds $row[0];
      
    $innings $thirds/3
      
    if (($thirds 3) != 0) {
        
    $innings .= ' '.$thirds 3.'/3';

    TuitionFree a free library for the self-taught
    Anode Says... Blogging For Your Pleasure


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •