VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Pure VB very fast MOA random numbers

by Rde (54 Submissions)
Category: VB function enhancement
Compatability: Visual Basic 5.0
Difficulty: Advanced
Date Added: Wed 10th February 2021
Rating: (1 Votes)

Powerful Pure VB Technique

This is 3 small VB modules that demonstrate a
rarely used but very powerful technique that
allow easy and fast multi-data-type transfers.

By using some simple UDT declarations you can
copy different data types from one to another
with no overhead and lightning fast too!

The secret is no secret at all, but is so rarely
seen you would think it was a secret - LSet.

This code demonstrates copying a Long to Currency
to allow unsigned arithmetic with no worries about
overflow or signed Long integer trouble. It then
copies the data back just as quickly and easily.

The most code efficient VB unsigned arithmetic ever!
This module now includes more detailed explanation.

A second small module demonstrates shifting bits.
Bit shifting is not a built-in operation in VB,
requiring multiplication, division and masking to
get the job done. If the shift is a multiple of
8 bits, this is now so fast and easy.

Just copy the low integer to the high integer and
zero the low to perform an 16-bit shift to the left.
Or copy the high integer to the low integer and zero
the high to perform an 16-bit shift to the right.

For rotations just simply copy one integer out, copy
the other over, then the first one back in.

Shifts in a multiple of 8-bits can be done for 16-bit
up to 64-bit data types using bytes, ints or longs,
all with code so simple and exceptionally fast too.

These techniques are demonstrated in another module
that performs Random Number Generation based on the
Mother Of All algorithm created by George Marsaglia.

This algo is truly fast with unbeatable output.

* Update 1: Improved demo modules.
* Update 2: Tweaked generator for more speed!
* Update 3: Modified InitSeed behavior.
* Update 4: Fixed bug in RandomRange.
See Changes.txt.

Rate Pure VB very fast MOA random numbers

Download Pure VB very fast MOA random numbers

Download Pure VB very fast MOA random numbers (17 KB)

Pure VB very fast MOA random numbers Comments

No comments have been posted about Pure VB very fast MOA random numbers. Why not be the first to post a comment about Pure VB very fast MOA random numbers.

Post your comment

Subject:
Message:
0/1000 characters