1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

PHP and Floats

Discussion in 'PHP' started by noppid, Jun 2, 2005.

  1. #1
    OK, I'm doing floating point math. I get the correct result on one of my servers, but my main server it gives incorrect results.

    One is php 4.3.10 the other is .11, I do not believe this has anything to do with the issue though.

    I have compared the phpinfo on both and cannot spot a difference for the life of me.

    Would anyone have a suggestion on this? No I didn't contact the host yet.
    SEMrush
     
    noppid, Jun 2, 2005 IP
    SEMrush
  2. varlik

    varlik Peon

    Messages:
    19
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    noppid, can you post a sample of your code along with the results from both versions? What version is the main server running? Are the servers running on different operating systems?
     
    varlik, Jun 2, 2005 IP
    noppid likes this.
  3. exam

    exam Peon

    Messages:
    2,434
    Likes Received:
    120
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I have had problems with floats on php 4.3.10/Win2000, but on my live (linux) server never had a problem...
     
    exam, Jun 2, 2005 IP
    noppid likes this.
  4. mushroom

    mushroom Peon

    Messages:
    369
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Both the OS and the CPU can limit the precision of your calaulations,

    so php may not be at fault,

    and with out knowing the legth of your "number" would guess the CPU is not as good in one machine.
     
    mushroom, Jun 2, 2005 IP
    noppid likes this.
  5. jbw

    jbw Peon

    Messages:
    343
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Are both servers running the same cpu? Used the same compiler to build ?
     
    jbw, Jun 2, 2005 IP
    noppid likes this.
  6. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #6
    I have to do the homework now. All of you have been big help. I can now compose a useful help ticket.

    I'll check back soon.
     
    noppid, Jun 2, 2005 IP
  7. rvarcher

    rvarcher Peon

    Messages:
    69
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Just ran across this in my php.ini

    
    ; The number of significant digits displayed in floating point numbers.
    precision    =  14
    
    Code (markup):
    It's listed in PHPInfo as Precision but, at least to me, I wouldn't have connected precision to floating point numbers (even though it makes sense now.)
     
    rvarcher, Jun 7, 2005 IP
  8. noppid

    noppid gunnin' for the quota

    Messages:
    4,246
    Likes Received:
    232
    Best Answers:
    0
    Trophy Points:
    135
    #8

    That was the first thing I checked. Both my servers are set the same. I have not had time to pursue this. It's out now and not worth the effort ATM to me.

    The tools here serve my purpose.
     
    noppid, Jun 7, 2005 IP