Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Logic gate tier rating

Name: Anonymous 2020-11-24 21:00

S:
NAND
A:
NOR
B:
NOT, AND
C:
OR
D:

E:
XOR
F:
XNOR

Name: Anonymous 2020-11-26 0:59

In PM they call nand incompatible with and symbolize it |

a|b := a nand b := a incompatible with b

Name: Anonymous 2020-11-26 10:04

xor is pretty based tbh, the cultured cryptographer's choice of logic gate

Name: Anonymous 2020-11-26 10:19

xor is for normies

Name: Anonymous 2020-11-28 4:23

these gates are actually boolean truth tables;
I've written a header with all such functions;
https://github.com/FrozenVoid/C-headers/blob/main/boolean-tokens.h

Name: Anonymous 2020-11-28 8:13

>>5
Cursed

Name: Anonymous 2020-11-28 11:32

>>6
What? Do you have any problems with compiling?

Name: Anonymous 2020-11-28 12:18

>>5
great reinvention of the wheel, FrozenAnus. can't wait until you find out about &&, || and !

Name: Anonymous 2020-11-28 12:45

>>8
This is token-level boolean manipulation, not compiled
code generation operators:
(see implemented variadic short-circuit in https://github.com/FrozenVoid/C-headers/blob/main/argmanip.h#L30 and generic variadic operators
via opapply(operator,args...) in https://github.com/FrozenVoid/C-headers/blob/main/argmanip.h#L12
)

Name: Anonymous 2020-11-28 12:54

>>9
words words words but what's the practical difference?

Name: Anonymous 2020-11-28 13:12

>>10
The expression (1 && 0 && 8) is evaluated by parser.
the boolean-tokens from #define are evaluated by pre-processor, expanding to C lexer compile time tokens 0 or 1

Name: Anonymous 2020-11-28 13:12

dubs gate

Name: Anonymous 2020-11-28 13:16

>>11
which is only useful if your're are working on constants. and when your're are working on constants and you know it, you could just precompute it. the real solution here would be for the compiler to recognize whether it's working on constants known at compile-time and then precompute it, or insert a boolean operator if your're are working on variables. I'm pretty sure C compiler does this already (to an extent, it's not the smartest compiler out there), so your're just wasting your're are time.

Name: Anonymous 2020-11-28 13:19

>>11
A more intuitive explanation;
given only a C pre-processor program(a text manipulation program),
you could use https://github.com/FrozenVoid/C-headers/blob/main/boolean-tokens.h to compute any boolean
expression without a compiler, purely due token replacement macros resolving to final values.

but argmanip.h macros will not be resolved
to final values without being parsed by gcc(the compiler).

Name: Anonymous 2020-11-28 13:31

>>13
the real solution here would be for the compiler to recognize whether it's working on constants known at compile-time and then precompute it.
boolean-tokens isn't a solution to anything,
its a handy tool for constructing logical circuits
with zero overhead; you compile time functions(e.g. C++ constexpr) have potential for bugs and depends
on C++ lexing rules. C preprocessor is simpler,
finite system that can be 100% be relied on.
Try rewriting boolean-tokens.h as C++ constexprs
and you will end with much larger, more complex and
bug-prone header.

Name: Anonymous 2020-11-28 13:34

>>15
I agree that C++ is not a good choice, because in general I don't like C++. but better C compilers (or even better - compilers for imperative languages which are easier to analyze statically, like Pascal or Ada) could potentially do what I'm talking about automatically.

Name: Anonymous 2020-11-28 13:37

>>15
here is typical use of boolean-tokens.h
to illustrate a simple logical circuit
#define custom_switchA 0 //disable flag A
#define custom_switchB 1 //enable flag B
#define custom_switchC 1 //enable flag C
//boolean_funcx/y are built on boolean-tokens.h primitives

if(boolean_funcx(custom_switchA,boolean_funcy(custom_switchB,custom_switchC)){code}

Name: Anonymous 2020-11-28 13:59

>>17 the pure C equivalent would be
something like
if(custom_switchA && !(custom_switchB^custom_switchC))
but any typo or number will be silently converted to
boolean expression (65&& !(0^3)), while the macros will error out with
"no match for pasting tokens x,y)" or syntax error
when you insert some extra operator in the arguments.

Name: Anonymous 2020-11-28 14:28

>>18
worse you can end up with something like
if(a&& (!(x!=y && x!=y2) || b==z)&& !(k && !m))

Name: Anonymous 2020-11-28 14:57

>>19
Now rewritten in elegant functional style
if(bool_and(
a,
bool_and(
bool_or(
bool_neg(
bool_and(
bool_xor(x,y),
bool_xor(x,y2))
,b==z))
,bool_neg(
bool_and(
k,
bool_neg(m))))))

Name: Anonymous 2020-11-29 0:01

>>5
#define bool_merge2_(a,b) a##b
#define bool_merge2(a,b) bool_merge2_(a,b)


What is the point of this? Why define two macros where the second one just calls the first?
I see a similar pattern too often but I have no idea what to google to figure it out.

Name: Anonymous 2020-11-29 4:20

>>21
forwarding for macro arguments(forcing expansion of arguments by forwarding it to another macro)
https://gcc.gnu.org/onlinedocs/gcc-3.4.3/cpp/Stringification.html Edited on 29/11/2020 04:46.

Don't change these.
Name: Email:
Entire Thread Thread List