For Programmers: Free Programming Magazines  


Home > Archive > Delphi > May 2004 > Double to variant conversion problem









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Double to variant conversion problem
Andrejs Shtrumfs

2004-05-12, 9:10 pm

Hi All!

I have some strange problem with variants. I have procedure:

1: procedure proc;
2: var
3: v: variant;
4: a: double;
5: begin
6: v := 38114.447165;
7: a := 38114.447165;
8: end;

Now, i place a breakpoint on the begin and try to step thru the code.
I step over the 6th line and check the value of variable v in the
evaluate/modify dialog. Somehow the value now is 38114.4. But when i
check value a, it is correct - 38114.447165. Why?!

Andrejs
Henry Bartlett

2004-05-12, 9:10 pm

> I have some strange problem with variants. I have procedure:
>
> 1: procedure proc;
> 2: var
> 3: v: variant;
> 4: a: double;
> 5: begin
> 6: v := 38114.447165;
> 7: a := 38114.447165;
> 8: end;
>
> Now, i place a breakpoint on the begin and try to step thru the

code.
> I step over the 6th line and check the value of variable v in the
> evaluate/modify dialog. Somehow the value now is 38114.4. But when i
> check value a, it is correct - 38114.447165. Why?!


Perhaps it's because the debugger does not know what type v represents
and so displays it using the default floating point type.

Try this
var b: double;
.......
{6a} b := double(v);
.......

What value do you see for b?


--
Henry Bartlett
HABit utilities ( http://www.hotkey.net.au/~hambar/habit/ )
email: hambar@Spamlock.microtech.com.au.
Please remove the "Spamlock." from my address when replying.




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com