Temporary Solution For DOUBLE FLOAT

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by VPureBasic.

Hi all,

If someone is looking for a temporary library to get a double float instead Fred will had a real one to Purebasic... here the solutions

goto http://www.reelmediaproductions.com/pb/asm.shtml
and download the file MakeDouble.zip

I hope this will help some...

Roger
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Danilo.

How do you pass the double to your Function MakeFloatDouble() ??

I dont think that this works, because you
can only specify LONG, BYTE, FLOAT, String etc...
in the Library Description, but no double.

Are the 3 commands shown in the example file
all commands ??

ADDITION:
OK, i tested it now. What do you want it
exactly to do ??
It just doesnt look right to me, thats the
reason i ask you. Hope you can help me.

MakeFloatDouble( 2.12 )
shows me 2.015 in the StringGadget

MakeFloatDouble( 2.10 )
shows me -2 and 2.0125 in the Window.

MakeFloatDouble( 2.1234567 )
shows me:
-36893488147419103000
2.015432

Sorry, i dont get it - please explain.

cya,
...Danilo

(registered PureBasic user)


Edited by - Danilo on 07 April 2002 02:41:03
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

I don't get it either...
What exactly does this let me do??
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by VPureBasic.

Hi guys,

The function MakeFloatDouble( XXX ) for example transfert a regular 32 bits to a 64 bits long value.

The Function DoubleHigh() Returns the First 32 bits of 64, or in DWord format.
The Function DoubleLow() Returns the Last 32 bits of 64, or in DWord format.

For an Example:
MakeFloatDouble( 3.1416 )
A.l = DoubleHigh()
B.l = DoubleLow()
[Double],[Double]...
Now people can use OpenGL Function as gluPerpective( A,B, C,D, ... )

I think that your looking for more about those functions but this will be more accesible when Fred, will make Double as variables call.

Or, If you think that the addition of functions as DoubleAddition, Substraction, and other math functions can help I'll do it. But I think that this will not be very helpful if you already have QWORD value to make math functions with...

For Now I write an update version that will return Long value for DoubleHigh() and DoubleLow() instead of Float... I made a mistake there :)

The file will be at: http://www.reelmediaproductions.com/pb/asm.shtml
the file name will be MakeFloatDouble.zip

NB. Paul please delete the first one...

Roger Beausoleil
Canada
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Hmmm... the DoubleAddition function doesn't seem to be any more acurate than adding Floats. Your sample program returns a wrong answer.

Fred, please give use real Doubles so we can do acurate math!!
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by VPureBasic.
Your sample program returns a wrong answer.
Hi Paul,

The answer of my sample is wrong not because my formula is wrong... but because the StrF() function.

The example is:
MakeFloatDouble( 3,1416 )
A.l = DoubleHigh()
B.l = DoubleLow()

MakeFloatDouble( 100.5 )
C.l = DoubleHigh()
D.l = DoubleLow()

E.f = DoubleAddition( A,B, C,D )

The good answer should be 103.5416
The wrong answer done by StrF( E ) is 103.541609
. ^^ I am not responsable of this

I wounder if it's not windows fault?!?

Anyways I wrote this because I would like to use OpenGL function and, know I can. I only thought those functions can help somebody as your request...

Roger
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by VPureBasic.

Hi

Excuse me but for the last message, you should read 103.6416 instead of 103.5416

Roger
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by Paul.

Ok, I understand :)
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by VPureBasic.

Hi paul,

I did another test and I find something that could be interresting for you...

When you make...

MakeFloatDouble( 3.1416 )
A.l = DoubelHigh()
B.l = DoubleLow()

MakeFloatDouble( 100.5 )
C.l = DoubleHigh()
D.l = DoubleLow()

E.f = DoubleAddition( A,B,C,D )

If you had a digit precision to StrF( E,4 ) you will the good answer as 103.6416 as your looking for...

Roger
BackupUser
PureBasic Guru
PureBasic Guru
Posts: 16777133
Joined: Tue Apr 22, 2003 7:42 pm

Post by BackupUser »

Restored from previous forum. Originally posted by theogott.

Why only DoubleFloat ?
Lets do the FULL STEP and use QuadrupleDoubleFloat wit at least 128 bits ...
How about a Vartype with an Variable bit-lenght ?
A compiler for that type would have the
worldwide scientist-community for shure ...

*************************
The best time to do things is now !
Post Reply