Skip to content
Low-level programming · Higher-level thinking
Login Register
Forum / Bugs and Fixes

negative float parameter

A community discussion post from the original code:zIRON forum.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

negative float parameter

Hi

it seems that zrion did not accept a negative float parameter

here is a prototype of the function

procedure PositionEntity=('_PositionEntity@16')(pointer Entity; single x,y,z); stdcall;

and here the calling

PositionEntity(ogrehead,0,0,-150);

any help please.

http://www.freewebs.com/ogremagic/index.htm

Replies

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I have fixed this in latest beta,

here

don't forget that in your sample you are passing value as integer, Ziron does not do type checking on functions so you need to pass it as a real4 (single)

myProc(0.0, 0.0, -150.0);

also if you at some point need to pass real8 or real10, they would need variables created since they are passed by pointer.

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

oh , i have just discover that.

the like is not found.

http://www.freewebs.com/ogremagic/index.htm

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

sorry the link is not found.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

It's the usual beta link, anyways had a typo fixed the link, try again....

Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

ok , downloaded and worked well , thanks.

about the real8 ,real10 parameter pathing , is there any work around or a trick to solve that

issue.

I have many functions with double parameters , such as Cairo library in my MagicPro library.

http://www.freewebs.com/ogremagic/index.htm

Colin admin
Posts
928
Threads
49
Location
Bulgaria

I have updated the beta again to fix a couple issues with doubles etc... so re-downlaod it.

i have an idea that may work but i will have to try around with it later...

else for now the normal way:

debugMB_Single(0, 2.6);

double dbVar = 2.6;
debugMB_Double(0, dbVar);

extended extVar = 2.6;
debugMB_Extended(0, extVar);

I may add type checking for floating values so we can easier get around this, but internally it technically would just be the same thing as above just without the extra var, it would still use the stack since it would pass it by ref.

For Ziron 2 i will come up with some better methods to overcome this. :)

btw i would suggest for performance reasons in your library to change your doubles to be double* this way you pass a pointer and can save size on the stack and make things quicker.

e.g.

procedure myProc(double* mydw) {
  //do something
}

double d = 5.0;
myProc(@d);
Emil_halim member
Posts
639
Threads
104
Location
Alex, Egypt

updating done, thanks.

i was thinking , make a macro or a plugin that will divide the extended value into 2 Dword

then push them in the stack.

something like that

inline procedure Dpl(extended x )
{
   divide x into X1 and X2
   push X2
   push X1
} 

then later

procedure myProc(double* mydw) {
  //do something
}

double d = 5.0;
myProc(Dpl(5.0));

so what do you think , and who to divide x ?

http://www.freewebs.com/ogremagic/index.htm