RE: Simple math failing - PHP Bug?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm



On 05 November 2004 10:42, Olaf van der Spek wrote:

> Mike Ford wrote:
> > for.  (Some early business-oriented computers, and some calculators
> > (especially financial ones) did use a system called binary-coded
> > decimal -- BCD -- to calculate "accurately" in the sense you mean,
> > but the fact that they were never widely used and have died out
> > almost totally should tell you something about their usefulness.)
> 
> Wasn't that just a way to store 11 as 0x11 and 56 as 0x56?
> x86 has BCD instructions too.

Effectively, yes -- although it wasn't very usual to talk in hex back in the
days when I learnt about BCD!

But it also meant that a number such as 564.29897 was stored as 0x564.29897
(if you see what I mean!), so there were none of these nasty
binary<=>decimal rounding approximations and you always had an exact answer
(to the limit of the number of significant figures supported, anyway).  But
it makes the calculations more complex as you effectively have to do
everything byte-by-byte (since neither 0x8+0x8 nor 0x4*0x4 is 0x16!), and
hence both more expensive and slower (sometimes *much* slower), even when
done in hardware.

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux