Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 04-02-03
ShowYouLoveThem
Guest
 
Posts: n/a
  This took me all day to figure out yesterday!


I just thought I'd post this in case its of any use to anyone and so as I can let out some of my frustration!

Have a look at this code: -
Code:
 <?
if (9.79*100==979) {
&nbsp &nbsp &nbsp &nbsp echo "PHP can multiply by 100!!";
} else {
&nbsp &nbsp &nbsp &nbsp echo "PHP CAN'T multiply by 100!!";
};
?>
Can you guess which answer it gives?!? ARGH!

Of course this showed up in an import routine that takes 6mins to run. It took ages to figure out what was going on.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 17-02-03
Notionlogic
Guest
 
Posts: n/a
  That's a real belter


To be honest when I first read your post, I seriously doubted you... sorry

Once I'd tried it out, it prompted me to do some further research into a "cure" and, for the record, this is what I came up with:

if (bccomp((9.79 * 100), 979) == 0) {
echo "PHP can multiply by 100!!";
} else {
echo "PHP CAN'T multiply by 100!!";
};

If tracked this down since in the PHP Manual it says: "...So never trust floating number results to the last digit and never compare floating point numbers for equality. If you really need higher precision, you should use the arbitrary precision math functions or gmp functions instead."

Thanks for the information though - It's probably saved me from making a really dumb error at some point in the future!

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 18-02-03
freebieholics
Guest
 
Posts: n/a
  Re: That's a real belter


Stick around NotionLogic,

You sound real handy. <img src=http://www.gamers-forums.com/smilies/contrib/ruinkai/biggthumpup.gif ALT=":thumb">
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Jamster TD and Zanox - is it me? grobinso The Affiliate Marketing Lounge 5 18-04-05 01:47 PM
Prezzybox Mothers Day Promotion... Spreader Merchant Promotions & Incentives 1 18-02-05 12:45 AM
credit cards - 7 day epc ashagplz Commission Junction - CJ UK 1 21-05-04 08:29 PM
Stuck for Mother's Day content? Bob Saver TradeDoubler 4 13-03-03 09:43 PM
Anyone else have a shocking day yesterday? luca brasi Commission Junction - CJ UK 7 02-09-02 08:23 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7