Float to Double
Posted: Sun Mar 14, 2004 10:01 am
I want to convert a float to double without using user library.. I had seen an ASM code that do that, but I lost it and I can't refind it... Does someone have it ?
http://www.purebasic.com
https://www.purebasic.fr/english/
; *Polo wrote:I want to convert a float to double without using user library.. I had seen an ASM code that do that, but I lost it and I can't refind it... Does someone have it ?
I don't see GiveDouble as a standard PB funciton. But here is what I use:Polo wrote:Thanks, but what is this GiveDouble() function ?
Code: Select all
Structure Double
Hi.l
Lo.l
EndStructure
Procedure MakeDouble(LONG.f, ADDRESS.l)
!FLD dword [ Esp ]
!MOV dword Eax, [ Esp + 4 ]
!FSTP qword [ Eax ]
EndProcedure
Procedure.l DrawImage(Left.f, Top.f, Width.f, Height.f)
dLeft.Double
dTop.Double
dWidth.Double
dHeight.Double
MakeDouble(Left.f, @dLeft)
MakeDouble(Top.f, @dTop)
MakeDouble(Width.f, @dWidth)
MakeDouble(Height.f, @dHeight)
ProcedureReturn CallFunctionFast(FPDrawImage, dLeft\Hi, dLeft\Lo, dTop\Hi, dTop\Lo, dWidth\Hi, dWidth\Lo, dHeight\Hi, dHeight\Lo)
EndProcedure
It shows you how to use the procedures.Polo wrote:Thanks, but what is this GiveDouble() function ?
also...Polo wrote:Thanks, it works !
Code: Select all
Procedure.f CatchDoubleReturn(*x.Double)
!MOV dword EAX,[ESP]
!FST qword [EAX]
!MOV dword EAX,[ESP]
!FLD qword [EAX]
EndProcedure
Code: Select all
Procedure.f GetHTMLTextHeight(Width.f, HTMLText.s)
dWidth.Double
MakeDouble(Width.f, @dWidth)
CallFunctionFast(FPGetHTMLTextHeight, dWidth\Hi, dWidth\Lo, HTMLText)
ProcedureReturn CatchDoubleReturn(dummy.Double)
EndProcedure
I think it is.. along with letting there be up to 40 parameters on aLarsG wrote:it's really a shame you should have to go through all that trouble, just to use a double variable...
Let's hope new variable types are high on Fred's priority-/todo-list..
Ehhhh - didn't know that... What is the limit now?NoahPhense wrote:along with letting there be up to 40 parameters on a
procedure..
Yeah, it's being moved up. SedTech said it was currently at 20techjunkie wrote:Ehhhh - didn't know that... What is the limit now?NoahPhense wrote:along with letting there be up to 40 parameters on a
procedure..
Hmmm - in a Digital Flight Simulator I programmed a couple of years ago we had over 600 parameters in the main call - no use of PB there I'll guess...
Well, it simulated a real aircraft and data for the engine was real engine data - impossible to simulate... As I remember, we had about 15000 variables in the system + the derivate of all variables... So - it was a big system, but it worked very well... in realtime...NoahPhense wrote:As for 600 parameters, that's just sick..
Well, you two could use Structures to pass Parameters to Procedures. This is recommended (at least by me) anyway, as it is faster and has more structure (no pun intended).techjunkie wrote:Well, it simulated a real aircraft and data for the engine was real engine data - impossible to simulate... As I remember, we had about 15000 variables in the system + the derivate of all variables... So - it was a big system, but it worked very well... in realtime...NoahPhense wrote:As for 600 parameters, that's just sick..![]()
About PB - if it is a limit of 20 parameters, that's real bad - I'm just lucky that I haven't broke the limit... *counting* Ehhhh - 18 parameters in that procedure... *LOL*
True, care for a quick example?freedimension wrote:Well, you two could use Structures to pass Parameters to Procedures. This is recommended (at least by me) anyway, as it is faster and has more structure (no pun intended).techjunkie wrote:Well, it simulated a real aircraft and data for the engine was real engine data - impossible to simulate... As I remember, we had about 15000 variables in the system + the derivate of all variables... So - it was a big system, but it worked very well... in realtime...NoahPhense wrote:As for 600 parameters, that's just sick..![]()
About PB - if it is a limit of 20 parameters, that's real bad - I'm just lucky that I haven't broke the limit... *counting* Ehhhh - 18 parameters in that procedure... *LOL*