Search found 1799 matches

by STARGÅTE
Wed Feb 21, 2024 1:31 pm
Forum: Coding Questions
Topic: StrD and Rounding
Replies: 17
Views: 606

Re: StrD and Rounding

My problem is... the "old" systems (Delphi, python and java) don't have problems with double. [...] @skywalk and STARGATE: thx for the clearing. My problem is, the old systems have no problems with converting and Math-Rounding. And the new Software has the have the same results. So yeah, ...
by STARGÅTE
Wed Feb 21, 2024 9:22 am
Forum: Coding Questions
Topic: AI output coding for purebasic
Replies: 11
Views: 633

Re: AI output coding for purebasic

Will the output code work ? No, because it is no Pure Basic code, it is just trash. "IncludeFile" has to be used to include files, not "#Include once" OpenWindow() has a wrong oder of arguments (see documentation) button.Caption, button.Width, etc. is no Pure Basic syntax. In Pu...
by STARGÅTE
Tue Feb 20, 2024 9:09 pm
Forum: Coding Questions
Topic: StrD and Rounding
Replies: 17
Views: 606

Re: StrD and Rounding

Maybe StrD and FormaNumber should get a rounding Flag. What kind of flag do you mean? In principle StrD works correct. If you have a number like 83.03125, this number is exact, also in binary format. Therefore StrD(Val, 4) gives correctly 83.0313 (rounding up). Define Val.d = 83.03125 Debug StrD(Va...
by STARGÅTE
Tue Feb 20, 2024 3:31 pm
Forum: Coding Questions
Topic: StrD and Rounding
Replies: 17
Views: 606

Re: StrD and Rounding

The "problem" is that your number 83.23195 do not exist in the computer system, just in you mind. At the moment you enter this number, the number is already "clipped" to 83.231949999999998, because it is the nearest number to 83.23195 which can be represented by a computer (for 6...
by STARGÅTE
Tue Feb 20, 2024 3:14 pm
Forum: Coding Questions
Topic: StrD and Rounding
Replies: 17
Views: 606

Re: StrD and Rounding

both should rounding up No, they shouldn't. No bug! The number created by ValD("83.23195") is 83.2319 499999999980 , because 83.23195 cannot be represented in as binary number. Rounding here at the fourth digit gives 2319. Define val1.d=ValD("83.23195000000001") Define val2.d=Va...
by STARGÅTE
Thu Feb 15, 2024 8:02 pm
Forum: Coding Questions
Topic: ReadPreferenceString() has a problem with unicode files
Replies: 5
Views: 249

Re: ReadPreferenceString() has a problem with unicode files

CreatePreferences creates always a UTF-8 file.
You can use the flag: #PB_Preference_NoBOM, to remove the usually set UTF8 BOM.
by STARGÅTE
Thu Feb 15, 2024 5:18 pm
Forum: Coding Questions
Topic: ReadPreferenceString() has a problem with unicode files
Replies: 5
Views: 249

Re: ReadPreferenceString() has a problem with unicode files

Since PB 6.10, OpenPreferences has an additional parameter for the Encoding, try it out:

Code: Select all

OpenPreferences("test.ini", 0, #PB_UTF8)
by STARGÅTE
Sun Feb 11, 2024 7:19 pm
Forum: Coding Questions
Topic: Issue with Sizeof() and may be other...
Replies: 5
Views: 358

Re: Issue with Sizeof() and may be other...

https://www.purebasic.com/documentation/reference/compilerfunctions.html Syntax Size = SizeOf(Type) Description SizeOf can be used to find the size of any complex Structure, built-in type (word, float, etc.), Interface or even ReferenceLink "variables" "variables" ( Structures w...
by STARGÅTE
Sat Feb 10, 2024 2:08 pm
Forum: Coding Questions
Topic: PB 6.10 beta 5 #PB_Any return value type changed?
Replies: 17
Views: 1194

Re: PB 6.10 beta 5 #PB_Any return value type changed?

This different memory behaviour between os with the same PB version can cause problems in some situations. Why? What kind of situation? It doesn't matter whether a memory location is large or small, as long as you use the correct variable type: Integer. I know, old codes here in the forum uses some...
by STARGÅTE
Thu Feb 08, 2024 7:15 am
Forum: Bugs - Windows
Topic: Wrong result for comparisons with NaN (ASM backend)
Replies: 2
Views: 283

Wrong result for comparisons with NaN (ASM backend)

Define.d Number1 = NaN() Define.d Number2 = 3.14 If Number1 > Number2 Debug StrD(Number1) + " > " + StrD(Number2) EndIf If Number1 < Number2 Debug StrD(Number1) + " < " + StrD(Number2) EndIf If Number1 = Number2 Debug StrD(Number1) + " = " + StrD(Number2) EndIf NaN > 3...
by STARGÅTE
Wed Feb 07, 2024 4:55 pm
Forum: Coding Questions
Topic: PB6.10 b5 Created Image fails being recognized.
Replies: 6
Views: 331

Re: PB6.10 b5 Created Image fails being recognized.

Why do you post this question in the bug section, if you can't reproduce the error in a short code? How should we reproduce the possible issue? Where do you think the bug should be? If IsImage( img ) is null, then img is (no more) valid image number. This could happen, when e.g. the image was freed.
by STARGÅTE
Sun Feb 04, 2024 11:26 pm
Forum: Coding Questions
Topic: PB 6.10 beta 5 #PB_Any return value type changed?
Replies: 17
Views: 1194

Re: PB 6.10 beta 5 #PB_Any return value type changed?

Not really a bug but something has changed for sure. In a program that interacts with COM what previously was interpreted as a VT_I4 (4 byte signed int) now has become a VT_R8 (8 byte floating point) it caused the program to crash. The returned gadget handles values seem to have widened, i would li...
by STARGÅTE
Sun Feb 04, 2024 8:12 pm
Forum: Coding Questions
Topic: PB 6.10 beta 5 #PB_Any return value type changed?
Replies: 17
Views: 1194

Re: PB 6.10 beta 5 #PB_Any return value type changed?

It is and was always integer (.i)
I think there was a change in memory management in the background.

But why you think it is a bug?
by STARGÅTE
Wed Jan 31, 2024 2:57 pm
Forum: Tricks 'n' Tips
Topic: Use "& operator" instead of modulo on power of 2 divisors
Replies: 5
Views: 628

Re: Use "& operator" instead of modulo on power of 2 divisors

The CPU instruction table for various CPUs show that the latency for DIV is aroung 15 and binary AND is just 1. This is also similar between Intel Cannon Lake (Intel 10th gen. Core) and Zen 2 (AMD Ryzen 3000). Probably the instruction Random() is the time limiting function in the loop. You should su...
by STARGÅTE
Tue Jan 30, 2024 9:42 pm
Forum: Tricks 'n' Tips
Topic: Use "& operator" instead of modulo on power of 2 divisors
Replies: 5
Views: 628

Re: Use "& operator" instead of modulo on power of 2 divisors

I see no difference with my Ryzen 9 3900X between ASM and C or optimized C. Also M_binMod is just 20% faster. What is you processor benubi, that the % operator is so slow for you? Test results Number of loops: 100,000,000 BinMod() function exec time ms: 555 M_binMod() macro exec time ms: 394 M_binMo...