Tuesday 1 February 2011

Various

This morning I got the basics of my currency conversion plugin for wordpress working (I think). When searching for info on how to convert a currency string to a number in PHP, I came across this post: PHP money string conversion to integer error.

According to various people on there, it seems that you shouldn't store decimal values (such as money) as floats, as it can sometimes produce incorrect figures:
Without going into too much detail, they store a number based on powers of two and since not all decimal number can be presented this way, it doesn't always work.

However, when I tried the example they gave (156.64*100 = 15663) in PHP, I found that I got the correct amount (i.e. 156.64*100 = 15664). So in my plugin I am letting PHP do automatic type conversion to float rather than treating the parts before and after the decimal point manually. (PHP doesn't support a decimal type).

In my currency conversion plugin I'm using Yahoo to get the conversion rates, a handy guide to Yahoo's financial quotes 'API' is http://www.gummy-stuff.org/Yahoo-data.htm

With that done, I did a bit more work on my ebay wordpress plugin. After lunch I did a virus scan with MSE while I did a couple more posts for my photography tips website. I don't think I've got a virus, but it was suggested as a possible reason for why some of my files had their permissions changed when I moved a folder.

When that was done I started a scan with Malware Bytes as that was recommended to catch things that MSE misses. I went out on walk to take some sunset photos. The walk was very nice, but the sunset wasn't that great, so the photos I took aren't that good.

In the evening I geo-coded the photos I'd taken and watched an episode of Magi Rangers and Let's Learn Japanese Basic I with Mauser and Bo.

No comments: