short to long works OK.
Thanks.
But I wonder why 64 bits is quite happy with short.
Just for fun, starfield with planets orbiting
Re: Just for fun, starfield with planets orbiting
This also worked with 'gcc 32-bit' (but not with 'gas').
Re: Just for fun, starfield with planets orbiting
I changed the datatype of m : dim as integer m = fix(size)
And leaving x and y as short : no freeze (gas32)
So ????
And leaving x and y as short : no freeze (gas32)
So ????
Re: Just for fun, starfield with planets orbiting
It gets stuck in the loop in 32 bits. sub grid_add_bol()
(actual values substituted)
(actual values substituted)
Code: Select all
dim as short a,b,x,y
dim as single m
m=-35878
a=m
m=35879
b=m
print a;" to ";b
dim as string s
for y = a to b step -100
for x =a to b step -49
s+="*"
next
next
print mid(s,1,50)
print "out"
sleep
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Just for fun, starfield with planets orbiting
I replaced every instance of short with long and went five minutes with gas, gas64, and gcc 32/64 without a freeze.
The moral of this saga is, do not use short unless we are 100% certain that will not be violated. However, if we use long, we don't have to worry about that.
Can anyone think of a reason why using long instead of short would be problematic?
OK we will use a bit more memory but is that a problem today? I doubt that we will notice any difference performancewise.
The moral of this saga is, do not use short unless we are 100% certain that will not be violated. However, if we use long, we don't have to worry about that.
Can anyone think of a reason why using long instead of short would be problematic?
OK we will use a bit more memory but is that a problem today? I doubt that we will notice any difference performancewise.
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Just for fun, starfield with planets orbiting
Off topic:
A lot of grahics programs use the default Rnd sequence, so we get the same output for every application session. To show your work in the best light, a different Rnd sequence should be used on every application session.
To accomplish that, we need to use Randomize. That will use a seed “value based on Timer”. The seed value should be double "but the fractional part is clipped for all algorithms except algorithm #4"
For a Windows session running for ten minutes will see a seed value of 600. Running for 24 hours will see a seed value of 86400.
The following will see a seed value between 0 and 4xGigs-1 no matter how long the Windows session.
The unlikely event of Seed = 0 will give the default Rnd sequence.
A lot of grahics programs use the default Rnd sequence, so we get the same output for every application session. To show your work in the best light, a different Rnd sequence should be used on every application session.
To accomplish that, we need to use Randomize. That will use a seed “value based on Timer”. The seed value should be double "but the fractional part is clipped for all algorithms except algorithm #4"
For a Windows session running for ten minutes will see a seed value of 600. Running for 24 hours will see a seed value of 86400.
The following will see a seed value between 0 and 4xGigs-1 no matter how long the Windows session.
Code: Select all
Declare Function RtlGenRandom Lib "Advapi32.dll" Alias "SystemFunction036" _
( RandomBuffer As Any Ptr, RandomBufferLength As Ulong ) As Byte
Dim As Ulong Seed
RtlGenRandom( @Seed, 4 )
Randomize Seed
-
- Posts: 4310
- Joined: Jan 02, 2017 0:34
- Location: UK
- Contact:
Re: Just for fun, starfield with planets orbiting
I had forgotten about this platform independent method.
On my machine, GetSeed returns in just less than one micro-second.
Code: Select all
Function GetSeed() As ULong
Dim As ULong Seed
Asm
rdtsc
bswap eax ' fast moving to upper bits
mov Dword Ptr [Seed], eax
End Asm
Return Seed
End Function
For i As ULong = 1 To 10
Print GetSeed
Next
Print
Dim tot As Double
For i As ULong = 1 To 10^8
tot += GetSeed
Next
Print "Average of 10^8:";tot/10^8
Print "Expected value:";2^31 - 0.5
Print "Ratio ";tot/10^8/(2^31 - 0.5)
Sleep
-
- Posts: 103
- Joined: Mar 08, 2016 19:10
- Location: The Netherlands
Re: Just for fun, starfield with planets orbiting
I see everyone had fun with my code
Sorry i did not have time to check all the replies.
I have seem to forget some checks not to go beyond memory pointers and data types.
The things is, i just start coding without a real plan.
When code comes along i go in a direction is i like, especial with this project.
My only pupres has been getting into coding again.
The function grid_add_bol() has serious problems.
Drawing a true sphere over a screen 32000+ pixels with is a bad idea.
Big thanks to all replays, really helping me.
I'm back in neural network again.
Sorry i did not have time to check all the replies.
I have seem to forget some checks not to go beyond memory pointers and data types.
The things is, i just start coding without a real plan.
When code comes along i go in a direction is i like, especial with this project.
My only pupres has been getting into coding again.
The function grid_add_bol() has serious problems.
Drawing a true sphere over a screen 32000+ pixels with is a bad idea.
Big thanks to all replays, really helping me.
I'm back in neural network again.