123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|518|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Blitz -> large numbers in blitz...

Thu, 27 Mar 2008, 10:21
Orion Pax
Ok in my game I have a pretty big universe and I need to know if this is going to affect it any...

My problem is I have stuff scattered out in a random x,y,z with a min of -100000000000000 and a max of 100000000000000. When I save an items location to disk it gives me exponentials of say .... -1.37047e+008 and 1.01149e+008. Now I know what it means...but if I load it back in will blitz read it like that and still position the item back in its correct location with that same number?
Thu, 27 Mar 2008, 11:11
Jayenkai
Blitz only uses 32 bit numbers..
This means you can only have positions between -2147483648 and 2147483647
Keep that in mind whilst defining your universe.



Limit in Action...


-=-=-
''Load, Next List!''
Thu, 27 Mar 2008, 12:06
JL235
I would recommend making the universe a little smaller, but if you want numbers that big you could just use a different language. Most languages support 64-bit long integers as well as the 32-bit integers that Blitz uses.
Thu, 27 Mar 2008, 13:35
Phoenix
Jay will hate me for mentioning DLLs, but they do exist.

I also agree with JL; make the universe smaller. It's the easiest solution.
Thu, 27 Mar 2008, 15:46
Jayenkai
There's no need to use such big numbers.
If a star is size 2000 and the next star is 10,000,000 away...
Make it smaller!
star = 2, planet = 0.05, next star = 10,000
sorted.
You don't NEED such big numbers, unless you MAKE a reason for such big numbers.

-=-=-
''Load, Next List!''
Thu, 27 Mar 2008, 16:34
mike_g
Maybe search the blitz archives to see if anyone has made a bignum library. Then there should be pretty much no limitation on the size of the number.

If you are going to code your own then you will need to write methods for each operation. I started on my own bignum libary in C not so long ago, but decided to dump it and restart in C++ (something I havent quite got arounnd to yet). Heres some examples I found useful:

https://homepages.ihug.co.nz/~aurora76/Malc/Useful_Classes.htm
ownloadcode/Arbitrary-precision_integer_arithmetic_%28C%29" target="_blank">https://en.literateprograms.org/Specialownloadcode/Arbitrary-precision_integer_arithmetic_%28C%29

Unfortunatly the code is in C++, and C, but it should give you an idea of how they work.
Thu, 27 Mar 2008, 16:46
JL235
If you want more examples of how to implement BigNum, it's very common in lots open source standard languages APIs. I'm pretty certain this is true for both Ruby and Java whilst also probably being implemented very differently in both.
Thu, 27 Mar 2008, 19:43
Orion Pax
Well its not the matter of forcing big numbers. I was just wondering why blitz was doing that and if it was gonna work like that. I will probably still use the full size but definitely reduce the size of everything else....
Fri, 28 Mar 2008, 08:37
HoboBen
Out of interest, if you implement double double precision integers, would the 3D engine still work at that size? Mathematically you might be sorted, but would you get MAVs or other problems?

But it's probably best not to load the entire universe at once (you won't be able to see it all, and if you could it would look strange) so maybe it would work to have a mathematically valid universe stretching as far as 64 bit integers allow, but stick to a nice small area for actual gameplay.




-=-=-
blog | work | code | more code
Fri, 28 Mar 2008, 09:36
Afr0
Hmm.... yeah... this sounds like a really bad idea to be doing in Blitz. AFAIK, none of the Blitz languages are threadsafe (3D *might* be, Max *isn't*), so just the implications of implementing this are going to be tough to handle.

-=-=-
Afr0 Games

Project Dollhouse on Github - Please fork!
Fri, 28 Mar 2008, 10:05
Jayenkai
Elite was done on a BBC Micro.

Your space game can be done in Blitz.

Just don't use big numbers.

-=-=-
''Load, Next List!''
Fri, 28 Mar 2008, 11:16
JL235
You could also split the universe up into sectors, and you only work with the current sector that the user is in and any nearby sectors that the user might cross into soon (like with Morrowind and Oblivion). Then the universe could have sectors from -2147483648 to 2147483647, which are each spanning from -2147483648 to 2147483647.
Fri, 28 Mar 2008, 15:04
mike_g
Well the sectors thing is pretty much what a bignumber library does anyway. W/o a bignum library you would need to implement your own carry system if you want say get distances and do other cross sector calculations. Personally I'd use an existing bignumber library. Or code a seperate bignum module. At least that way it would be reusable for different projects.
Fri, 28 Mar 2008, 15:37
Orion Pax
I was going to do sectors but it was proving to be a bit difficult to implement and just decided to leave out the idea of sectors and just have everything in there.

Another thing that has came up is from what I can see, I am going to have A LOT of entities in the game. And I have heard that even tho they are not seen, they will slow the game down. So what I was going to do is to do this...

Set the camera distance to like 10,000. Then, only load stuff that is with in a 15,000 distance. And anything that goes beyond that limit gets free'd. I will have everything loaded into types and with locations stored in them so it wont be too hard to do this. Just have to figure it out. Maybe just make a function that checks the distance of everything each loop...and as they come into view...create the entity. And as they leave...free em.
Fri, 28 Mar 2008, 15:49
Jayenkai
And easier thing to do might be to give each entity an orbit around a planet.
Even if something isn't in orbit!!!

That is to say..
Imagine you've 5 chunks of floating debris around the outside of a solar system.
If you say they're "Orbit of sun, Distance 5000, No movement" then you can set it up to only ever draw them when you're within a large range of the sun..
Similarly, planets only appear when you're near the system, and moons when you're close enough to the planet.
So long as you structure every element as a part of each other element, you'll be able to load the smaller chunks as you close in on the larger ones.

-=-=-
''Load, Next List!''
Sat, 29 Mar 2008, 18:20
Orion Pax
Rnd(-2147483600,2147483600)

Ok I am using that in my game but Blitz is still producing exponential numbers. I think I will just make a quick and dirty test program and see if blitz will print out the old number or the new number.
Sat, 29 Mar 2008, 18:31
Orion Pax
If I use the Int() function on it after I read it from the file its fine. So I just x#=int(readline(filein)) and I get my results.

I also tested on a number bigger than a 32 bit number it produces it in non notational but that doesnt mean blitz will let me place something in 3D space that far out and not freak out. So I will just stick with the limits.

|edit| Never mind...it doesnt produce any numbers larger than its limit. Dunno why I thought that number was big enough until I counted the places. |edit|
Sun, 30 Mar 2008, 05:52
Phoenix
Use Rand() instead of Rnd().
Sun, 30 Mar 2008, 15:10
Orion Pax
I tried that and it seemed not to produce any random numbers. Kept getting either -2147483600 or 2147483600. And I actually need floating point numbers as movement can be 0.0. Not that its generating parts of a whole. And it kept producing numbers in notation as well. Either way I have a fix for it...so I am not worried about it.
Sun, 30 Mar 2008, 17:40
JL235
Your storing it as a float, that explains the problem. Due to how floating point numbers work, they are only so accurate. Although you can hold very large and very small numbers with a float, you can only add on numbers which are close to it. For example run the following code:

It prints out 1 million in both cases even though I have added on 1. This is because 1 million is too big for me to then add on a 1.

What is strange though is that in both Java and C you can add 1 to 1 million in a float, although the same will happen if the float gets a lot higher. Java and C just seem to have 'better' floats. They also have doubles allowing even more bigger and smaller numbers.

I'd recommend using integers only as I suggested above, split the universe into sectors and then have float movement within that. That way when a position gets up to say 100,000 it'll be at the edge of the sector and you can just take it back down to 0.
Mon, 31 Mar 2008, 14:09
mindstorm8191
I have to agree with Jayenkai, there's no need to use big numbers just for the sake of it. I remember a lot of games where all the points were in increments of 100. What difference does that make?

If you still need a solution for the big numbers thing, here's one to consider. A BigNum library would be good, but it would be a lot easier to divide your universe into sections. So a location is both a sector value plus a 2D/3D location.

-=-=-
Vesuvius web game
Sun, 11 May 2008, 15:36
LostUser
BigInt was a really big issue for me, and was one of the major reasons why I stopped programming in B2D.

I could even get up to post 2 million. But for some reason, I can get up to 10 million now. I don't know why.

Anyway, during the process of trying to figure it out, the closest solution I had were:

* To use an abacus system where a Type had billions, millions, units, etc. Whilst reading about abacuses I found that the Japanese Soroban sounded like a good library to make (https://en.wikipedia.org/wiki/Soroban)
* Use a Dim/Array to hold the big number Type with billions, millions, thousands and units.

* Its easy to do +/- but I got really stuck with */- and gave up.

The only reason I used big numbers was for my "attempt" at cloning "Trump:The Board Game" where it has millions, and even billions and I used a system where it was:



But then I couldn't decide at what point a million becomes a billion. I would stick to the American way (ie: 1000m = 1 Billion) as the old UK way of doing it really gets confusing.

I hope all this helps.
Sun, 11 May 2008, 16:59
JL235
The array idea sounds interesting, or more an array of 64 ints where one is to represent each bit in order to recreate a long integer.
Tue, 04 Jun 2013, 11:45
dna
I hate to resurrect an old post but why is this code


not printing the numbers in between?

0.0
0.5
1.0
. . .

-=-=-
DNA