Search found 1274 matches

by Munair
Jul 24, 2023 1:08
Forum: Beginners
Topic: Searching for bytes in a block of memory
Replies: 3
Views: 1446

Re: Searching for bytes in a block of memory

If it's about real memory blocks, rather than array elements, consider allocating memory and scan the block for specific data. It's quite easy to mark the start and end of a block of specific bytes: dim as uinteger ptr p dim as uinteger null, max dim as integer i, x, y dim as uinteger size dim as ui...
by Munair
Jul 14, 2023 7:03
Forum: General
Topic: How to select and copy the contents of the console
Replies: 9
Views: 642

Re: How to select and copy the contents of the console

On Linux consoles Ctrl+A/C/V do not work. Instead, they support the old (DOS) keys Ctrl+Ins (copy) and Shift+Ins (paste) whereby Ins is the Insert key.
by Munair
Jul 12, 2023 19:21
Forum: Beginners
Topic: shl shr optimization bug?
Replies: 22
Views: 4617

Re: shl shr optimization bug?

A compiler might also ignore calculations that cancel each other out: c = (c shl 2) shr 2 whereas separate calculations yield separate (correct) results: c = 3221225512 c = c shl 2 print c ' 160 c = c shr 2 print c ' 40 I wouldn't rely on the first one. But if you know what the compiler does, maskin...
by Munair
Jul 10, 2023 13:43
Forum: General
Topic: can function's identifier serve as UDT instance?
Replies: 2
Views: 407

can function's identifier serve as UDT instance?

While adding UDT support to the SB compiler, I was wondering, wouldn't it be elegant to have a function's identifier directly serve as a UDT instance? After all, a function of a numeric or string type has its initial return value set to 0 or null-string. So I was thinking of something along these li...
by Munair
Jul 09, 2023 20:46
Forum: General
Topic: Suspicious logic operation, mixed boolean and non-boolean operands
Replies: 11
Views: 823

Re: Suspicious logic operation, mixed boolean and non-boolean operands

if I understand correctly, IF (INTEGER OR INTEGER) OR BOOLEAN ... is evaluated to IF INTEGER OR BOOLEAN ... I was thrown off by the fact that this does not raise a warning, whereas IF INTEGER OR BOOLEAN OR BOOLEAN does. Not quite (maybe you mistyped?) Yes, I mistyped, I meant IF (INTEGER = INTEGER)...
by Munair
Jul 09, 2023 15:44
Forum: General
Topic: Suspicious logic operation, mixed boolean and non-boolean operands
Replies: 11
Views: 823

Re: Suspicious logic operation, mixed boolean and non-boolean operands

Thanks coderJeff. Yes, I'm well. OK, I understand the complexity due to backwards compatibility and if I understand correctly, IF (INTEGER OR INTEGER) OR BOOLEAN ... is evaluated to IF INTEGER OR BOOLEAN ... I was thrown off by the fact that this does not raise a warning, whereas IF INTEGER OR BOOLE...
by Munair
Jul 08, 2023 18:31
Forum: General
Topic: QB64 faster than FB ?
Replies: 41
Views: 2194

Re: QB64 faster than FB ?

dodicat wrote: Jul 08, 2023 15:15 Here is my div from first principles, not very fast.
The result of your code on 64-bits Manjaro-Linux:

7966 0.02222800254821777

7966 0.0001721382141113281
by Munair
Jul 08, 2023 14:08
Forum: General
Topic: Suspicious logic operation, mixed boolean and non-boolean operands
Replies: 11
Views: 823

Re: Suspicious logic operation, mixed boolean and non-boolean operands

You are mixing logical, bitwise and relational operations: Print s1 Or s2 '' => integer '30' prints the result of a bitwise operation, whereas: if s1 Or s2 then ... is a logical operation yielding a boolean result to test if the expression is true or false. Since, my examples are IF- statements, any...
by Munair
Jul 08, 2023 12:51
Forum: General
Topic: Suspicious logic operation, mixed boolean and non-boolean operands
Replies: 11
Views: 823

Re: Suspicious logic operation, mixed boolean and non-boolean operands

Logic operation between two numeric values induces a numeric value. Logic operation between two boolean induces a boolean. As in theory any logic operation mixing a boolean and a numeric operand is undefined, so a compiler error would be expected. That doesn't sound right. A logical operation by de...
by Munair
Jul 08, 2023 6:34
Forum: General
Topic: QB64 faster than FB ?
Replies: 41
Views: 2194

Re: QB64 faster than FB ?

This is why compilers should be so keen on avoiding the div/idv instruction whenever possible:
https://forum.nasm.us/index.php?topic=3863.msg15882#msg15882
by Munair
Jul 08, 2023 6:24
Forum: General
Topic: Suspicious logic operation, mixed boolean and non-boolean operands
Replies: 11
Views: 823

Re: Suspicious logic operation, mixed boolean and non-boolean operands

Code 5 OK: dim as integer a, b dim as boolean flg1, flg2 if (a = b) or (flg1 or flg2) then print true else print false end if Yes, it underlines the lhs - rhs parsing issue. Perhaps this is due to the fact that the same token (=) is used for both assignment and comparison, although in this case the...
by Munair
Jul 07, 2023 19:38
Forum: General
Topic: Suspicious logic operation, mixed boolean and non-boolean operands
Replies: 11
Views: 823

Suspicious logic operation, mixed boolean and non-boolean operands

I cannot believe I actually ran into this warning message. I tested two non-booleans along with two booleans in an IF statement and FBC generated this warning: " warning 38(1): Suspicious logic operation, mixed boolean and non-boolean operands ". Code 1: dim as integer a, b dim as boolean ...
by Munair
Apr 05, 2022 7:13
Forum: Sources, Examples, Tips and Tricks
Topic: UTF-8 Variable Length String Library
Replies: 47
Views: 10849

Re: UTF-8 Variable Length String Library

Linux already speaks UTF-8 natively so I think there is no need for an UTF-8 library for it. FreeBASIC has no string manipulation routines built in that support unicode. For example, taking the first 10 characters of a string with LEFT(text, 10) really takes the first 10 bytes , which means that if...
by Munair
Apr 05, 2022 5:37
Forum: Sources, Examples, Tips and Tricks
Topic: UTF-8 Variable Length String Library
Replies: 47
Views: 10849

Re: UTF-8 Variable Length String Library

PCHAR is a windows data type. If windows.bi is included, PCHAR will be defined. This library having been developed on Linux is not aware of datatypes on other platforms. In any case, simply commenting out the definition in UTF8.bi will not be the solution, unless the definition is identical (zstrin...
by Munair
Apr 04, 2022 11:14
Forum: General
Topic: [SOLVED] Pass UTF-8 strings
Replies: 35
Views: 2813

Re: Pass UTF-8 strings

const char* translates to CONST ZSTRING PTR Example test_C_function(@"test 中国語") VAR c_str = @"test 中国語" '' creates a ZSTRING PTR test_C_function(c_str) ?LEFT(*c_str, 4) ?MID(*c_str, 6) The UTF8 library pointed to by Vortex has both zstring ptr and const zstring ptr defined as: ...