Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #963
| From | Robert van der Hulst <E-55525A53-4141-E@heliks.nl> |
|---|---|
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: What's wrong with this cast? |
| Date | 2011-04-27 11:42 +0200 |
| Message-ID | <19010142267.20110427114237@heliks.nl> (permalink) |
| References | <s87er6d3aomad9n4sjrh8ucetm5usn9aji@4ax.com> |
Hi D.J.W., On Tue, 26 Apr 2011, at 21:33:11 [GMT +0200] (which was 21:33 where I live) you wrote about: 'What's wrong with this cast?' > In a method where a subtraction is supposed never to yield <0 it did > nevertheless as the variable was a dword it gave a run time error. > I decided to work with floats inside (realized later that int was > better, but that is not the issue now ) and after checking for non > zero values, I assigned : > nStockDW:=DWORD(_CAST,nStock) > where nStock=float > nStockDW = dword > However: the first value of nStock (1,00) did not yeild dword 1 but a > huge number like 43423454554645, and a run time error after use of > course. > What is wrong with this conversion? if nStock is a float, then you are casting the address of the float to a DWORD. Floats are a reference type in VO. You can easily see that by doing the cast twice and running CollectForced() in between: nStockDW:=DWORD(_CAST,nStock) CollectForced() nStockDW:=DWORD(_CAST,nStock) You will see that the second cast returns a different value. Like Jamal said: nStockDW := DWORD(nStock) will do the trick. However when nStock is negative then this could throw a runtime error (depending on the overflow compiler setting) -- Robert van der Hulst AKA Mr. Data www.heliks.nl
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
What's wrong with this cast? D.J.W. van Kooten <public@ic2remove.this.com> - 2011-04-26 21:33 +0200
Re: What's wrong with this cast? "Jamal" <vodotnet_nospam@yahoo.com> - 2011-04-26 16:38 -0400
Re: What's wrong with this cast? D.J.W. van Kooten <public@ic2remove.this.com> - 2011-04-26 22:46 +0200
Re: What's wrong with this cast? "Geoff Schaller" <geoffx@softwarexobjectives.com.au> - 2011-04-26 22:17 +0000
Re: What's wrong with this cast? Robert van der Hulst <E-55525A53-4141-E@heliks.nl> - 2011-04-27 11:42 +0200
Re: What's wrong with this cast? D.J.W. van Kooten <public@ic2remove.this.com> - 2011-04-27 17:41 +0200
Re: What's wrong with this cast? "Geoff Schaller" <geoffx@softwarexobjectives.com.au> - 2011-04-28 22:26 +0000
csiph-web