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.

AppGameKit Classic Chat / dInt & Double Variable Assign & Signed & Unsigned question

Author
Message
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 6th May 2014 22:32
Hi,

I have search this forum and on google/yahoo and found no result.

Is there a way to Assign "Double"/"DInt" to a variable without using float?

The Reason i need this is because a application i am current task to program need the precision of of Integer without Going Decimal.

As if you use "*" and/or "/", the result returned, tend to fluctuate.

So is there anyway to have Double Int?
Without hitting a Cap of 2,147,483,647?

Also how do one assign Signed/Unsigned integer without using a function to convert this?
AGK seem to have it Signed by Default.

Any Help on this 2 topic Highly Appreciated!

Thank You for your time!

Regards
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th May 2014 22:56 Edited at: 6th May 2014 23:23
i believe a integer/float is 32 bit in agk and with sign because u need often +- for a value.
http://www.appgamekit.com/documentation/principles/1_datatypes.htm

using 64 bit or more will be very special because u need +-*/ ... also.
don\'t know what you need, if speed is not the problem u can use strings.
or request new data type with more bytes.
i believe u need 8byte integer or "signed IEEE 64-bit (8-byte) double-precision floating-point numbers"

did u have a example with fluctuate */ ?

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 7th May 2014 04:40 Edited at: 7th May 2014 05:05
You will probably have to code your own, as Markus suggested strings are probably the best way to go.

Add and subtract are easy enough and Here's a little snippet I whipped up for Multiplication



Divide might need a bit more work.

Edit:
Quote: "Without hitting a Cap of 2,147,483,647?"

For size comparison, the following would pass the cap of an unsigned Double Int

4294967296 x 4294967296 = 18446744073709551616 (2^64)

Attachments

Login to view attachments
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 7th May 2014 17:07 Edited at: 7th May 2014 17:10
Markus:

for fluctuation, Try this:


change value2 to another digit to find the flux
In some case, you get back 1270.999972 <= or something similar

Trunc() will just return 1270, instead of 1271.

Marl:

i also work in "Industrial Automation".
Where most of the PLC has a 32Bit RISC Processor.

Some of them support "Double" and even "Quad" integer storing & Processing.

So yes, it would be great if AppGameKit support "Double" without going tier2, as some application is preferred to be simple.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 7th May 2014 21:25
your problem is if u have a higher integer value part (at limit) you loss
the decimal places. because the type is a floating point.
i had remove one place at subtract and it looks ok.
i agree a double float would be better for you.



AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 8th May 2014 00:24
Some need for care. AFAIK OpenGL can only use 32-bit signed or unsigned integers. Back conversion needed!

-- Jim - When is there going to be a release?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 8th May 2014 04:33
Of course, if you went Tier 2, you'd be able to do it easily.

Cheers,
Ancient Lady
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 8th May 2014 12:13
Markus:

At this url: http://www.appgamekit.com/documentation/Reference/Core/Timer.htm
It describe the problem clearly:

Get the number of seconds and fractions of seconds since the app was started. Accurate to milliseconds, but due to floating point inaccuracies the longer the app is running the less accurate this becomes, this value will start to lose precision after approximately 2 hours of running.

Ancient Lady:
True, but sometime i just wanna finish it in under an hour without worrying about importing, programming additional stuff, and compiling.

JimHawkins:

Sorry, what has this got to do with a graphic Driver like OpenGL?
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 8th May 2014 13:52
Chmava - Quite a lot. AppGameKit uses OGL. You would have to be careful when passing integers to AppGameKit functions.

As Ancient Lady correctly, as always, says - if you want to do precise calculations its better to use C/C++ or Pascal. The TDateTime variable in Delphi or Free Pascal is a double-precision floating-point value, not a single as in AGK's timer.

-- Jim - When is there going to be a release?
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 8th May 2014 14:11 Edited at: 8th May 2014 14:13
JimHawkins:

so OGL only support Single-PF?
And as such, AppGameKit has to be build around it?

Anyone:

Also, is there a way to detect application has focus?
For Windows....
JimHawkins
14
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 8th May 2014 14:25
Correct.

AGK is effectively a cross-platform tool-set for OGL. Consequently, its Basic implementation uses the same precision.

I don't actually agree that it's faster to program using the Basic, because you have to put up with the limitations of the language and the implementation. I'd guess that 80%+ of the problems reported on the forum are Basic-related - some are just naivety and some are bugs in the Basic implementation.

-- Jim - When is there going to be a release?
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 8th May 2014 14:27
if os hide a app and it goes pause mode, we get only once
GetResumed() to bring game in pause mode for user.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 11th May 2014 17:35 Edited at: 11th May 2014 17:37
Markus:

i was referring to the fact that timer will run in the BG without pausing the game, and thus, completely mess up scoring & stuff relating to timer.
Example, user check their eMail and came back to see a "Game Over" Screen.

I was looking at another method of combining basic with Tier 2 at near the end of development to speed up production time.

Wonder if it is possible.

JimHawkins:

i wonder if there is a DirectX version just for windows. as most application use OpenGL as DiectX is proprietary to Microsoft and as such not available on other system like Android.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th May 2014 18:26
about timer, agree but we have GetFrameTime() to count the time/seconds we need.

AGK 108 (B)19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
Chmava
10
Years of Service
User Offline
Joined: 20th Jun 2013
Location:
Posted: 11th May 2014 20:43 Edited at: 11th May 2014 20:52
Markus:

I believe GetFrameTime() is only use to find FPS?

Game like Terraria seem to pause when not focus by the mouse?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 12th May 2014 02:57
Quote: "I believe GetFrameTime() is only use to find FPS?"

No, it isn't.

GetFrameTime() returns the time it took to display the previous frame.

Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-04-27 14:25:40
Your offset time is: 2024-04-27 14:25:40