Search found 2879 matches

by Richard
Mar 19, 2019 3:15
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

Compress the universe to a 1 x 1 grid and you have your singularity! The interesting question there is the size of the dictionary needed to regenerate the universe from 1 bit. Many string theory physicists believe that the content of a volume of the universe is fully expressed as a hologram on the ...
by Richard
Mar 15, 2019 23:36
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

I think you already wrote it , but i need a converter , to convert base 256 ascii , to base 10. Can you give me a link to it? I don't know exactly what you mean. My converters go both ways so you need to accurately and separately describe the two formats you are converting between. Is the data in a...
by Richard
Mar 15, 2019 14:55
Forum: General
Topic: Self-referential initialisation by Dim.
Replies: 7
Views: 353

Re: Self-referential initialisation by Dim.

For the most curious case, it seems that "dim as integer x = x" means "dim as integer x = any" , yes? Dim As Integer x = Any; does not initialise x so it saves time. Dim As Integer x = x; has the same outcome but wastes time doing it, so I see no advantage in the feature. Where ...
by Richard
Mar 15, 2019 2:20
Forum: General
Topic: Self-referential initialisation by Dim.
Replies: 7
Views: 353

Self-referential initialisation by Dim.

There was a time when Constants could be declared that referred to themselves. That time has now passed and the compiler correctly complains. But now I find I can Dim and initialise a self-referential variable. Is this a new bug, or is it necessary or acceptable for some reason ? Dim As Double a = a...
by Richard
Mar 14, 2019 22:58
Forum: General
Topic: Substitute text into a string
Replies: 4
Views: 345

Re: Substitute text into a string

Thanks @Foneo.
Your demonstration code solved the problem neatly.
by Richard
Mar 14, 2019 7:15
Forum: General
Topic: Substitute text into a string
Replies: 4
Views: 345

Substitute text into a string

How can I put the body of a #define into a string so it can be printed ?
If I use #define identifier “body” the quotes get in the way of substitution elsewhere.

Code: Select all

#define identifier body
Dim As String txt
txt = " identifier "
Print txt  ' I want it to print 'body', not 'identifier'
by Richard
Mar 13, 2019 5:19
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

Albert wrote:Whats the opposite of the "Big Bang"?
What do they call it , when the universe compresses back to a single star?
The Big Crunch.
https://en.wikipedia.org/wiki/Big_Crunch
by Richard
Mar 10, 2019 12:36
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

If dodicat had not shown While...Wend was faster than Do While .. Loop and eliminated the If, I would not have looked for and found x Xor= x And -x. When I found that I went looking to see if it was already in play. That is when I found Brian Kernighan’s x And= x-1. So if Albert hadn't asked, dodica...
by Richard
Mar 10, 2019 8:30
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

Avoiding the terminal test 2/3 of the time only made it 7% faster, but here, even with the terminal test always done, it is about 33% faster. ' Brian Kernighan’s Algorithm Function fast_bitcount( Byval x As Ulongint ) As Integer Dim As Integer count = 0 While x x And= x - 1 count += 1 Wend Return co...
by Richard
Mar 10, 2019 5:21
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

Avoid 2/3 of the unlikely tests.

Code: Select all

Function count_bits( Byval x As Ulongint ) As Integer
    Dim As Integer count = 0
    While x
        count += x And 1
        x Shr= 1
        count += x And 1
        x Shr= 1
        count += x And 1
        x Shr= 1
    Wend
    Return count
End Function
by Richard
Mar 10, 2019 3:15
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

Given k set bits, the smallest number with k bits set is (2^k)-1, the biggest number with k bits set is decided by the size of your representation of a binary number. It requires factorials to count the number of different permutations of k set bits in an n place binary number. Count = n! / ( k! * (...
by Richard
Mar 07, 2019 6:44
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

@Albert. Data compression is trivial. You and many others have imaginative ideas for data compression. It is reversing the compression to regenerate the original data that is difficult. You should not post compression code unless you can reliably regenerate the data. Try writing some code that looks...
by Richard
Mar 06, 2019 4:42
Forum: General
Topic: Squares
Replies: 6384
Views: 365845

Re: Squares

Albert wrote:I got a data compressor working... It can't decompress yet , it just compresses so far..
I like your confidence. But how do you know it is not just a hash function?
by Richard
Feb 19, 2019 5:26
Forum: General
Topic: How to "customize" the random generator?
Replies: 18
Views: 739

Re: How to "customize" the random generator?

This code generates normally distributed random numbers. Given the mean, mu, and the standard deviation, SD; x = mu + SD * probit( Rnd ) Acklam's approximation of the probit() function used here is accurate to 9 digits. '----------------------------------------------------------------------- ' gener...
by Richard
Feb 12, 2019 23:34
Forum: General
Topic: How to "customize" the random generator?
Replies: 18
Views: 739

Re: How to "customize" the random generator?

Here is a cleaned up and documented example of my code. '----------------------------------------------------------------------- ' generate integers from a set of { 0 to nmax }, where ' each outcome has an independently specified probability '---------------------------------------------------------...

Go to advanced search