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 / EVALUATE 11111111.11*2.0=22222222 WHY why not 22222222.22 ?

Author
Message
OldPMan
TGC Store Seller
17
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 8th Mar 2010 18:00
Calculations of expression 11111111.11 * 2.0 = 22222222 why not 22222222.22


What should I do to make it - 22222222.22

.....already beside..... for all
Dragon Knight
19
Years of Service
User Offline
Joined: 10th Jan 2007
Location: Newcastle
Posted: 8th Mar 2010 21:06
That's the limitation of that data type, you could always make your own data type to store larger numerical values, but at the end of the day, when are you going to require such a precise numerical system in games.

You see it's all in how the numbers are stored and processed, you can only send so many binary digits in powers of 2. hence the wide range of data types consisting with different sized packets, anyway.. you can look up individual constraints for different numerical values on msdn.

As you'll notice 11111111.11 doesn't even print out like that, it rounds it. but if you put it in a string like so.. wolla it prints out what you wanted.. You can then take that further by taking apart the string and multiplying individual components and carrying over the new value then putting that into a new string, i'd show you how but I'll leave that up to you.



Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Mar 2010 21:30
The problem is probably that single precision arithmetic seems to be used for double floats as discussed in the last few posts of the following bug report:

problems with double floats, etc

This means that the last few significant digits are meaningless or at best inaccurate.
OldPMan
TGC Store Seller
17
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 8th Mar 2010 22:04
turns out that using the standard commands DBPro I simply can not correctly calculate 11111111.11 * 2.0 = TO 22222222.22

.....already beside..... for all
OldPMan
TGC Store Seller
17
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 9th Mar 2010 09:31
EXPRES$= "11111111.11 * 2.0"
A = EVALUATE EXPRESSION(EXPRES$) IN STYX The same result.
HOW TO TELL ME HOW TO derive the correct.
CAN HELP DLL and whether there is such.

.....already beside..... for all
Dragon Knight
19
Years of Service
User Offline
Joined: 10th Jan 2007
Location: Newcastle
Posted: 9th Mar 2010 09:48 Edited at: 9th Mar 2010 10:04
here quick example:


I didn't include the carry on purpose, to allow you to do it properly

TIP: If you go to do this properly, you'll have to take apart the b# to check for "." then you'll have to multiply accordingly. Next you'll have to add the carry and only reset it if the next character is not a ".".

dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 9th Mar 2010 09:59
Works fine here:




Notice the remaining .22 when I subtract the integer component from the value. The issue is just that literal values are always 32 bit, the 64 bit computations work fine.

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Mar 2010 12:21
Dark Coder

I don't think you are completely correct about literals - see the code below.

Anyway, your comments have made me re-visit the bug report I mentioned above. It seems that the problem is the use of the text command in my earlier sample code - just using it seems to interfere with the stored double float values!!

Try the following code, once without the text command, and once with, and compare the results.



What do you think? Is there a simple reason why this should happen?
dark coder
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 9th Mar 2010 13:42
Quote: "Is there a simple reason why this should happen?"


Now that... is stupid, if you move the line then it changes , even if you put it before you assign the values, it's like it changes their data type.

OldPMan
TGC Store Seller
17
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 9th Mar 2010 13:50 Edited at: 9th Mar 2010 13:51
I FOUND HERE DLL Is it possible to Connect to DBPro
ForevalZ(v.1.3.5) - compiler of mathematical expressions(formulas) with complex numbers given as string at 'run-time' (math parser).
(dll library + component). For use in calculations with complex numbers.
Main properties:
unlimited length and nested of expression
Supported main functions.
addition floatpoint variables (complex and real), integer variables and arrays
addition external functions with unlimited and indefinite number variables
For calculations only with real numbers use Foreval
Compiled with Delphi 6 or higher
license: freeware with source
author: Sorel, Russia
e-mail: [email protected]
[email protected]
web: http://dmanx.narod.ru
http://forevalz.sourceforge.net

.....already beside..... for all
OldPMan
TGC Store Seller
17
Years of Service
User Offline
Joined: 10th Aug 2008
Location:
Posted: 9th Mar 2010 21:25
found it - long ago in 2003 was post from David T - http://forum.thegamecreators.com/?m=forum_view&t=19033&b=5
Not quite a plugin but thois does the job just as well.

Thanks David T

.....already beside..... for all
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Mar 2010 17:18
I hate floating point. just use a integer or dword and split it up where you want your decimal point. So lets say you wanted the decimal point after the first two bytes. The hiword word be left of the decimal and the loword would be to the right. DBP floats SUCK lol i had problems with this before, and fixed percision did the trick. You can create functionss to do the splitting too.



you could even make it so you could specify the offset in bits to where the decimal point would be.

New Site! Check it out \/
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Mar 2010 17:42
Does that work with all the maths operations and functions?
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 12th Mar 2010 21:03
Who exactly was that directed toward? lol if it was to me then no, but if you had your own little functions it would be fine. It worked for what i was doing. although i don't know what he is using the numbers for exactly.

New Site! Check it out \/
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 13th Mar 2010 00:50
Quote: "Who exactly was that directed toward?"


You.

Quote: "if it was to me then no"


I thought not.

Quote: "but if you had your own little functions it would be fine"


A tall order.

All we're asking is that double float arithmetic is done correctly and consistently and doesn't depend on whether or not we've included "text" or "str$" or "set display mode" or other apparently irrelevant commands and functions in our code.

Login to post a reply

Server time is: 2026-07-27 07:33:32
Your offset time is: 2026-07-27 07:33:32