Re: Singles to Doubles
- From: "Michael C" <nospam@xxxxxxxxxx>
- Date: Mon, 23 Jul 2007 11:47:33 +1000
"dpb" <none@xxxxxxx> wrote in message news:f7l5rp$iqn$1@xxxxxxxxxxx
The part about assuming whether the number came from base 10 or was
possibly from somewhere else I don't understand at all. In the context of
VB, all external representations are base 10 unless explicitly coded as
Hex$ or Oct$ in which case the base is also known and explicit. There is
no assumption of base ever required, the only "assumptions" in what I was
trying to describe had to do with what one is to assume trailing digits
are for added precision when there isn't any information
providing them.
The number could have come from anywhere. It could have been passed to VB by
some external hardware, from a database, from a file or from a webpage. When
we have a single or double stored by VB we can't assume that number was
originally base 10. Hence we can't apply optimisations on the conversions
from single to double based on the assumption that the number is a base 10
number. Base 10 is simply the method VB usually (but not always) choses to
display the number. Karls method of converting to a string and back to a
double is what I would consider an optimisation based on the assumption the
binary number represents a base 10 number.
To see what is going on internally, find Tony's post and paste his code in
and look at the actual bit patterns and it will probably become much more
clear. Or, google on "floating point conversion" or similar and amongst
the zillion of hits pretty early on there will be sites that have floating
point calculators that you can type numbers into and see their internal
representations.
I know what's going on internally, I wrote something in dot net so I could
remind myself (having uint and ulongs it was much easier). I've written my
own 32bit maths routines in assembly language for the 8051 which is an 8 bit
processor so I know this stuff well enough. I didn't write floating point
routines but writing integer maths routines gave me a good idea of what's
going on.
Again, I heartily recommend at least reading through Goldberg's paper even
if you don't study it in depth...
http://docs.sun.com/source/806-3568/ncg_goldberg.html
I'll have a look when I get a chance.
Michael
.
- Follow-Ups:
- Re: Singles to Doubles
- From: dpb
- Re: Singles to Doubles
- References:
- Singles to Doubles
- From: Karl E. Peterson
- Re: Singles to Doubles
- From: Bob Butler
- Re: Singles to Doubles
- From: Karl E. Peterson
- Re: Singles to Doubles
- From: Jim Mack
- Re: Singles to Doubles
- From: Michael C
- Re: Singles to Doubles
- From: dpb
- Re: Singles to Doubles
- From: Michael C
- Re: Singles to Doubles
- From: dpb
- Re: Singles to Doubles
- From: Michael C
- Re: Singles to Doubles
- From: dpb
- Re: Singles to Doubles
- From: dpb
- Re: Singles to Doubles
- From: Michael C
- Re: Singles to Doubles
- From: dpb
- Singles to Doubles
- Prev by Date: Re: Looking for API equvalent of xcopy command
- Next by Date: How that is done?
- Previous by thread: Re: Singles to Doubles
- Next by thread: Re: Singles to Doubles
- Index(es):
Relevant Pages
|