## Search found 2878 matches

Feb 10, 2019 20:58
Forum: General
Topic: How to "customize" the random generator?
Replies: 18
Views: 739

### Re: How to "customize" the random generator?

dist( i ) contains the probability distribution of each integer coming up. Here is the code with output 10 having 100% chance, all others = 0%. ' setup an initial Probability Distribution Function Randomize Dim As Double dist( 0 To 63 ) For i As Integer = 0 To 63 dist( i ) = 0 ' an arbitrary startin...
Feb 10, 2019 6:34
Forum: General
Topic: How to "customize" the random generator?
Replies: 18
Views: 739

### Re: How to "customize" the random generator?

This code gives random integers, biassed by your arbitrary probability distribution. ' setup an initial probability distribution Randomize Dim As Double dist( 0 To 63 ) For i As Integer = 0 To 63 dist( i ) = 100/64 ' an arbitrary starting value, here percentage Next i ' you can arbitrarily change th...
Feb 05, 2019 1:52
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

@Albert. Until you get an algorithm working correctly, and find a real use for it, speed is not important. To access strings Mid(,,) will be slow; string[index] will be faster for single bytes; pointers will be fastest for 1 to 8 bytes. When you convert 4 random bits to bcd = digits 0 to 9, what do ...
Feb 03, 2019 10:17
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

One issue is that you are reading 8 bytes at the time from the string by using a UlongInt pointer. That produces 8 ascii digits, which then gets converted to binary, so it will fit easily in a 32 bit Ulong. It is important that the string be a multiple of 8 digits long, or there will be a bounds err...
Feb 01, 2019 4:49
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

@Albert. This makes it easy to understand and does not require acres of constants. '--------------------------------------------------------- ' make working variables and constant at the same time Dim As String num8 = "00000000", txt = num8 Dim As Ulongint Ptr p_num8 = Cast( Ulongint Ptr, ...
Jan 31, 2019 22:30
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

It might be fastest on your system but is not consistently faster on mine.
It is testing the speed of your cpu internal pipeline and cache for 64 bit data.
You need to examine the asm code actually generated by the compiler for each inner loop case.
Jan 31, 2019 3:55
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

You DO NOT need to embed the actual number in the code to get speed, the compiler will work it out once at compile time. It comes down to the question; Which of the following five is the most obvious, and least likely to get wrong? 2^56 1uLL shl 56 Bitset( 0uLL, 56 ) &h0100000000000000uLL 720575...
Jan 30, 2019 22:27
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

@Albert.
2^56 is a double precision number, with only 52 bits of accuracy.
1ULL Shl 56 is the exact number, as a long integer with 64 bits.

Code: Select all

`Print 2^56Print "  "; 1ULL Shl 56`
Jan 23, 2019 4:58
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

You must reverse the order you convert the elements when you fill the array of Short variables.
Convert the string in one direction, the array in the other.
Jan 20, 2019 2:51
Forum: Community Discussion
Topic: Moderator's Environment and Tools.
Replies: 4
Views: 450

### Moderator's Environment and Tools.

Following the recent call for moderator nominations. TJF. Thank you for the nomination, but I must decline, I moderate elsewhere. Dodicat is old and wise enough to sensibly turn down the invitation. Imortis has his heart in the right place, but will need to improve his telepathy. “Decimation” was a ...
Jan 11, 2019 23:44
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

@Albert.
My code showed you how to propagate carry, or to repair simple examples of delayed carry. Your code must avoid delaying carry for so long that local carry overflows within your register.
Jan 11, 2019 2:12
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

See; "Date and Time Functions", Date Serial and Time Serial. Now() gets the date and time in a Double.

Code: Select all

`#include "vbcompat.bi"Dim a As Double = Now()Print Format(a, "yyyy/mm/dd hh:mm:ss") Print Hour( a ), Minute( a ), Second( a )`
Jan 08, 2019 2:55
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

You are ignoring the carry when you add decimal strings that are really binary. You must keep a separate track of carry when you add in binary. Here is one way to clear carry in your previous problem. Dim As String a = "101110111100110100111001010100" Dim As String s = "01212335456688...
Jan 08, 2019 1:16
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

@Albert.
I am not surprised since you are using decimal addition to do binary addition and delaying carry for too long.
Jan 06, 2019 2:32
Forum: General
Topic: Squares
Replies: 6384
Views: 365803

### Re: Squares

@Albert. I have no idea what you think you are doing. But it seems you need to propagate carry by sweeping from right to left. 0001101110010000 = ans. 0001020302010000 = me. 0001020302010000 2 dec is 10 bin 0001020310010000 3 dec is 11 bin 0001021110010000 2 dec is 10 bin 0001101110010000 carry is n...