Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / Return Negative Float?

Author
Message
Tv Xxx
11
Years of Service
User Offline
Joined: 23rd Sep 2007
Location: Behind You!
Posted: 5th Apr 2009 20:27
I'm just messing around with making a dll, and I can't make it return a negative float...

its the quadratic equation...



it runs in DBpro, and returns the positive float fine, but the negative just returns 0...

any ideas?

Yours Tv.


Click my signature for free webhosting!
chunks chunks
12
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 6th Apr 2009 21:03
hasn`t it got to be signed to use negative values i`m not sure with floats but thats the case with ints .


chunks

nvidia geforce 8600gt + amd athlon 64
windows xp pro.
Rudolpho
13
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 7th Apr 2009 22:58
Yeah, well, first out you're using a DWORD, which is definitively not a float...
Furthermore, as chunks said, a DWORD is unsigned, so even if the cast actually succeeds it wouldn't be able to yield any negative values.

What's the deal with the DWORD part anyway, can't you just return the float?

Tv Xxx
11
Years of Service
User Offline
Joined: 23rd Sep 2007
Location: Behind You!
Posted: 7th Apr 2009 23:20
I dunno why it has to be a DWORD but thats what it said in the help files in dbpro...

yours Tv


Click my signature for free webhosting!
Diggsey
13
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 8th Apr 2009 00:20
The DWORD part is correct. (If you use float, C++ passes it through one of the floating point registers instead of pushing it onto the stack).

The reason it is always positive is simple, you are checking 'if (p = 1)'

What that does is assigns 1 to p, and then checks if p is non-zero. What you want is:
'if (p == 1)'

[b]Yuor signutare was aresed by a deslyxic mud...
BOX2D V2 HAS HELP FILES! AND A WIKI!

Login to post a reply

Server time is: 2019-07-17 18:39:58
Your offset time is: 2019-07-17 18:39:58