Search found 208 matches

by hhr
Apr 12, 2024 19:42
Forum: Sources, Examples, Tips and Tricks
Topic: OpenB3D ASCII Art
Replies: 2
Views: 200

Re: OpenB3D ASCII Art

Where can I get OpenB3D?
A good library archive would be helpful.
by hhr
Apr 12, 2024 16:45
Forum: Sources, Examples, Tips and Tricks
Topic: Simple 2D Ball Collision Demo
Replies: 9
Views: 613

Re: Simple 2D Ball Collision Demo

@ UEZ
My screen is too small.
Instead of

Code: Select all

Const w = 1920
Const h = Int(w * 9 / 16)
Const h2 = h Shr 1
I tried

Code: Select all

Dim As Long w, h, h2
Screeninfo w, h
h2 = h Shr 1
by hhr
Mar 28, 2024 17:34
Forum: Sources, Examples, Tips and Tricks
Topic: Cairo animated spiral
Replies: 11
Views: 591

Re: Cairo animated spiral

Interesting example. I wanted to know what Cairo was needed for and simply removed Cairo. Without Cairo the points are shaking, with Cairo the points are calm. This is achieved by transparency (or grayscale) in the outer pixels, which is why the dots appear smaller when Cairo is used. But it's a mys...
by hhr
Mar 03, 2024 21:12
Forum: Sources, Examples, Tips and Tricks
Topic: my newest bits read / write
Replies: 2
Views: 278

Re: my newest bits read / write

A suggestion for an example: dim as udecimal a,b,c,d a = cudeci("123456789.123230000023000001") b = cudeci("545676666.997555555559999999") c = a + b d = b - a print udeci_str(c),udeci_str(d) c = c + d print udeci_str(c) d = b + b print udeci_str(d) print c = d, c > d, c >= d, c <...
by hhr
Mar 03, 2024 20:04
Forum: Beginners
Topic: Picture doesn't show until I click outside the graphics window
Replies: 3
Views: 360

Re: Picture doesn't show until I click outside the graphics window

I can confirm that. I have used tire.jpg from FBImage and the following example. Compile example, select exe file, press enter repeatedly. It seems to work reliably with put, but only sometimes with MultiPut. In the command prompt it does not seem to work at all with MultiPut. #include "FBImage...
by hhr
Feb 21, 2024 10:11
Forum: Sources, Examples, Tips and Tricks
Topic: Connected balls
Replies: 1
Views: 173

Connected balls

#cmdline "-s gui" Open Scrn As #1 : Close #1 ' Wait until console is active, useful in Linux with QTerminal Dim As Long w = 800,h = 600 Screenres w,h Window (0,0)-(1,1) Dim Shared As Single r,dt,c,d r = 0.01 ' radius dt = 0.02 ' interval c = 0.02 Type ball Dim As Single x,y,vx,vy End Type...
by hhr
Feb 17, 2024 8:35
Forum: General
Topic: Console window during graphics
Replies: 4
Views: 306

Re: Console window during graphics

You can try this line. The system waits until the console is active. If you then start a graphics window, the console window remains in the background. Open Scrn As #1 : Close #1 ' Wait until console is active In Linux, the line is useful when using QTerminal because QTerminal starts slowly. In othe...
by hhr
Feb 12, 2024 22:40
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

@ badidea, caseih, neil
Thanks for the helpful comments.
by hhr
Feb 11, 2024 18:18
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

This also works with sprintf: #Include "crt.bi" Dim As Double n,a(1 To ...) = {997.931, 997.932, 997.933, 997.934, 997.935, 997.936, 997.937, 997.938, 997.939} Dim As Zstring*20 zs Dim As Integer DecimalPlaces For i As Long = Lbound(a) To Ubound(a) n = a(i) Print "Original number &quo...
by hhr
Feb 10, 2024 18:03
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

Unfortunately, your suggestion does not work if the last digit is 1 or 3. Line 10 in the following suggestion seems to work. The disadvantage is that DecimalPlaces must be equal to the number of decimal places required in Print Using. Dim As Double n,a(1 To ...) = {997.931, 997.932, 997.933, 997.934...
by hhr
Feb 09, 2024 22:13
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

What should I say to that?
by hhr
Feb 09, 2024 10:08
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

How do you want to test for errors in a program that outputs many rounded numbers?

Errors occur anyway when calculating with doubles, so small rounding errors are irrelevant.
by hhr
Feb 06, 2024 21:09
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

@neil Print Using also works quite well. However, it makes similar errors as printf and sprintf, although it does not seem to use these functions. Dim a As Double a = 997.935 Print "original number ";a Print Using "###.##"; a Print String(20,"-") a = -643.435 Print &quo...
by hhr
Feb 06, 2024 18:56
Forum: Sources, Examples, Tips and Tricks
Topic: Rounding numbers
Replies: 48
Views: 4715

Re: Rounding numbers

With this example I am trying to test printf. I hope that the numbers used for testing are put together reasonably. #Include "crt.bi" Function printfToString(number As Double, decimals As Integer) As String Dim As Long i,row,column Dim As String s,exponent s = Str(number) 'Copy the number ...