Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #11996 > unrolled thread
| Started by | Martin <Martin@spam.spam> |
|---|---|
| First post | 2018-09-24 09:48 +0100 |
| Last post | 2018-10-31 10:16 +0000 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
Type cast issue, never seen before Martin <Martin@spam.spam> - 2018-09-24 09:48 +0100
Re: Type cast issue, never seen before Robert van der Hulst <rjvanderhulst@gmail.com> - 2018-09-24 02:37 -0700
Re: Type cast issue, never seen before Martin <Martin@spam.spam> - 2018-10-31 10:16 +0000
| From | Martin <Martin@spam.spam> |
|---|---|
| Date | 2018-09-24 09:48 +0100 |
| Subject | Type cast issue, never seen before |
| Message-ID | <poa8dm$q8k$1@dont-email.me> |
Hello All I am casting a float to a DWORD before sending it off to a C routine nNew := DWORD(_CAST,nOld) nOld is 983.0000 nNew is a random number generated by DWORD 983.00 511849756 983.00 512025408 983.00 512137148 983.00 512317164 Anyone have any ideas?
[toc] | [next] | [standalone]
| From | Robert van der Hulst <rjvanderhulst@gmail.com> |
|---|---|
| Date | 2018-09-24 02:37 -0700 |
| Message-ID | <c504e135-cca0-41a8-a63a-1f51a6c41b01@googlegroups.com> |
| In reply to | #11996 |
Martin, You should not use _CAST here. If you want to convert a float to a dword use the following syntax dwValue := DWORD(floatValue) The _CAST tells the compiler that you know what you are doing and that you do not want the compiler to tell you that you are doing that you should not do. In this case you obviously don't know that. If you write dwValue := DWORD(_CAST, floatValue) then you are assigning the address of the float (float is a dynamic type in VO) to the DWORD variable. As a general rule of thumb I would say that if your app does not do what you expect it to do, then first have a look at the places where you are using _CAST. Robert Robert > Hello All > > I am casting a float to a DWORD before sending it off to a C routine > > nNew := DWORD(_CAST,nOld) > > nOld is 983.0000 > nNew is a random number generated by DWORD > > 983.00 511849756 > 983.00 512025408 > 983.00 512137148 > 983.00 512317164 > > > Anyone have any ideas?
[toc] | [prev] | [next] | [standalone]
| From | Martin <Martin@spam.spam> |
|---|---|
| Date | 2018-10-31 10:16 +0000 |
| Message-ID | <prbvdu$ddl$1@dont-email.me> |
| In reply to | #11997 |
Thank you Robert We fixed it by making sure the C can handle the float! Martin On 24/09/2018 10:37, Robert van der Hulst wrote: > Martin, > > You should not use _CAST here. If you want to convert a float to a dword use the following syntax > > dwValue := DWORD(floatValue) > > The _CAST tells the compiler that you know what you are doing and that you do not want the compiler to tell you that you are doing that you should not do. > In this case you obviously don't know that. If you write > > dwValue := DWORD(_CAST, floatValue) > > then you are assigning the address of the float (float is a dynamic type in VO) to the DWORD variable. > > As a general rule of thumb I would say that if your app does not do what you expect it to do, then first have a look at the places where you are using _CAST. > > > Robert > > > Robert > >> Hello All >> >> I am casting a float to a DWORD before sending it off to a C routine >> >> nNew := DWORD(_CAST,nOld) >> >> nOld is 983.0000 >> nNew is a random number generated by DWORD >> >> 983.00 511849756 >> 983.00 512025408 >> 983.00 512137148 >> 983.00 512317164 >> >> >> Anyone have any ideas? >
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web