Search found 1496 matches

by jj2007
Aug 04, 2020 20:01
Forum: Beginners
Topic: Stuck writing a simple bit toggle routine
Replies: 19
Views: 488

Re: Stuck writing a simple bit toggle routine

Sorry dodicat, the assignment can't be inside the #Define dodicat's solution works perfectly: Dim flag_ As integer=0 #define tog(flag_, position_) flag_ = flag_ xor (1 shl position_) tog(flag_, 2) print "flag_=", flag_ tog(flag_, 2) print "flag_=", flag_ sleep If one 32-bit flag...
by jj2007
Aug 04, 2020 10:52
Forum: Beginners
Topic: Stuck writing a simple bit toggle routine
Replies: 19
Views: 488

Re: Stuck writing a simple bit toggle routine

dodicat wrote:You could split the difference with a macro
You could do an awful lot of very complicated things, but a simple flags=flags xor 32 (e.g. for toggling bit 5) is faster and shorter and does the job, too.
by jj2007
Aug 03, 2020 21:12
Forum: Beginners
Topic: Stuck writing a simple bit toggle routine
Replies: 19
Views: 488

Re: Stuck writing a simple bit toggle routine

Toggling a bit: Dim MyInt As integer=0 MyInt=MyInt xor 1 print "MyInt=", MyInt MyInt=MyInt xor 2 print "MyInt=", MyInt MyInt=MyInt xor 2 print "MyInt=", MyInt MyInt=MyInt xor 1 print "MyInt=", MyInt sleep Output: MyInt= 1 MyInt= 3 MyInt= 1 MyInt= 0
by jj2007
Aug 01, 2020 21:09
Forum: General
Topic: A PRNG for graphics programs?
Replies: 84
Views: 1724

Re: A PRNG for graphics programs?

Ha. Given your dedication and enthusiasm for the the field, I feel like there should be a 'deltarho scale' for measuring randomness of a PRNG in some magnitude of 'randomish'. If such a thing doesn't exist yet, I feel like you would be the one to create it. Thanks again for sharing your talent. I e...
by jj2007
Aug 01, 2020 8:07
Forum: Beginners
Topic: MKDIR Question
Replies: 6
Views: 240

Re: MKDIR Question

Wouldn't it be nicer to update FB instead of the documentation? For example, MakeDir allows this (and it was no rocket science writing it):

Code: Select all

  MakeDir "tmp\new\folder"
  .if Zero?
   PrintLine "created"
  .else
   PrintLine "not created: ", Err$()
  .endif
by jj2007
Jul 31, 2020 19:42
Forum: General
Topic: Suspicious pointer assignment
Replies: 14
Views: 269

Re: Suspicious pointer assignment

In principle, Callocate() could return an address which doesn't fall on a word or dword boundary. In practice, however, under Windows you'll find HeapAlloc under the hood, and that one returns a QWORD boundary. I can't speak for Linux, though.
by jj2007
Jul 31, 2020 13:42
Forum: General
Topic: A PRNG for graphics programs?
Replies: 84
Views: 1724

Re: A PRNG for graphics programs?

when the stock markets crashed in March and everyone was leaving in droves I went in I had the same idea, actually, but my Core i5 notebook is just over 9 years and I don't feel like throwing it into the dustbin. Although I must confess that Windows rot is going on my nerves. Right now I am deletin...
by jj2007
Jul 31, 2020 12:33
Forum: General
Topic: Suspicious pointer assignment
Replies: 14
Views: 269

Re: Suspicious pointer assignment

Parameter 4 of sendmessage is a longint or lparam, not a pointer SendMessage has a parameter called "lParam" for historical reasons. It has been a DWORD for over twenty years now. That DWORD can be a pointer, a handle, an integer, a long, a float. It's all documented at Microsoft docs. Th...
by jj2007
Jul 31, 2020 12:17
Forum: General
Topic: A PRNG for graphics programs?
Replies: 84
Views: 1724

Re: A PRNG for graphics programs?

deltarho[1859] wrote:On my machine the average of every Rnd in the sequence took only 23 milliseconds
Ok, so the sequence is 2^24 here, I had overread that - sorry. Your machine is a bit faster than mine ;-)
by jj2007
Jul 31, 2020 11:45
Forum: General
Topic: A PRNG for graphics programs?
Replies: 84
Views: 1724

Re: A PRNG for graphics programs?

'#define Rnd NR.RandD' is not required. "Rnd in code will be replaced by NR.RandD". See the bottom of NR32.bas. I had embedded that in nr32.bas '#define elements 10000000' is too much for the default stack size, use Shared. Any BASIC dialect should recognise that and throw an error. I get...
by jj2007
Jul 31, 2020 10:58
Forum: General
Topic: A PRNG for graphics programs?
Replies: 84
Views: 1724

Re: A PRNG for graphics programs?

In opening post: "Rnd in code will be replaced by NR.RandD" Thanks, got it. Now why does this simple code throw an exception? I've checked it under the hood, something has trashed the stack pointer... #define Rnd NR.RandD #define elements 10000000 Dim My(elements) As double, ct As Ulong D...
by jj2007
Jul 31, 2020 10:16
Forum: General
Topic: Suspicious pointer assignment
Replies: 14
Views: 269

Re: Suspicious pointer assignment

bfilptr[0]=GetTickCount() could be justified saying "I only need the byte" (but it's ugly and should require a type cast) bfilptr[0]=dwfilptr[0] is an error, fullstop. There is no excuse for not throwing an error. One should see this also in the light of the numerous useless warnings for a...
by jj2007
Jul 31, 2020 9:07
Forum: General
Topic: Suspicious pointer assignment
Replies: 14
Views: 269

Re: Suspicious pointer assignment

Yes, the any ptr is a bit clearer. Still, bfilptr[0]=1234 does not throw an error. That's a big fat FB compiler bug . There is a warning 25(0): Overflow in constant conversion, which is nice but not sufficient. Assigning 1234 to a byte is an error . Even worse: bfilptr[0]=dwfilptr[0] does not even i...
by jj2007
Jul 31, 2020 8:40
Forum: General
Topic: Suspicious pointer assignment
Replies: 14
Views: 269

Re: Suspicious pointer assignment

Excuse my ignorance: which are the dire, catastrophic consequences of ignoring the compiler warning? Where is the madness? Dim buffsize As ULong=1000 Dim bfilptr As UByte Ptr Dim wdfilptr As UShort Ptr Dim dwfilptr As ULong Ptr bfilptr = Callocate( buffsize ) wdfilptr = bfilptr dwfilptr = bfilptr Pr...
by jj2007
Jul 31, 2020 8:26
Forum: General
Topic: A PRNG for graphics programs?
Replies: 84
Views: 1724

Re: A PRNG for graphics programs?

Excuse my ignorance: how do you use it? Dim My() As Ulong, ct As Ulong For ct=0 To 99 ??? Next Sleep What do you mean with "every Rnd in the sequence", i.e. how many numbers (of which type) did you generate in 23 milliseconds? the average of every Rnd in the sequence took only 23 milliseco...

Go to advanced search