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.

DarkBASIC Professional Discussion / Floats returned from DLL

Author
Message
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 01:57
When returning a float value into a variable and then printed, the output is completely wrong.
Yes, I really am THAT good...
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 25th Oct 2002 05:22
yeah...had this conversation a few times.

what language are you coding in? c++ and dbp don't seem to use compatible versions of the term 'float'

lee recommended something along this line (which i haven't had a chance to verify yet):
void GetFloatValue(){
return (DWORD)12.0;
}

-= i only do what my rice krispies tell me to do =-
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 12:02
Yes, I thought DBPro and C++ floats weren't compatiable. The trouble with the example you gave is that there would be a compiler error (cant return values with void functions).

Doubles seem to work okay, so I'll probably ignore floats for the time being.

Yes, I really am THAT good...
GCEclipse
21
Years of Service
User Offline
Joined: 23rd Sep 2002
Location: United Kingdom
Posted: 25th Oct 2002 12:51
Wow! I've been banging my head up against a wall for the last couple of days with a problem that is clearly caused by this issue with floats. If only I'd known.

So, if you create a file which uses C++ floats in them is there any way to read the information in DBPro?

MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 25th Oct 2002 13:37
It appears not - according to ChipOne, the format for floats in C/C++ and DBPro seem to be different.

I think the easiest way (for the time being at least), is to use doubles

Yes, I really am THAT good...
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 27th Oct 2002 02:50
hmmm...i'd agree on the compiler error thing. my code wasn't verbatem from Lee. here it is:



...which Lee says will stuff the float value into the EAX register for DB to pick up. I'm going to be getting back into this tomorrow, so I'll give this a try and let you all know...

-= i only do what my rice krispies tell me to do =-
MrTAToad
21
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 27th Oct 2002 02:52
Do tell us what you find.

Yes, I really am THAT good...

Login to post a reply

Server time is: 2024-03-29 10:18:43
Your offset time is: 2024-03-29 10:18:43