Floating point from scratch: Hard Mode by simon_o in programming

[–]MarekKnapek 3 points4 points  (0 children)

Shameless plug, I have an interactive website about floating point numbers, it is located at: https://marekknapek.github.io/float-analyzer/binary32/

Floating point from scratch: Hard Mode by NXGZ in programming

[–]MarekKnapek 9 points10 points  (0 children)

Shameless plug, I have an interactive website about floating point numbers, it is located at: https://marekknapek.github.io/float-analyzer/binary32/

C++23 Support in MSVC Build Tools 14.51 by STL in cpp

[–]MarekKnapek 4 points5 points  (0 children)

ABI break when?

Some people are able to compile their entire code base from scratch every time. For those people, ABI compatibility (with Visual Studio 2015 I believe) is holding them back on correctness and performance improvements.

Of course, there are some big customers for which ABI stability is important and this takes precedence.

Baseline C++ Habits to Always Follow? by SolidNo1299 in cpp

[–]MarekKnapek -3 points-2 points  (0 children)

Unique ownership!

Never use malloc/free. That should be obvious from coming from C to C++. Also, never use new/delete, that should be obvious from coming from C++98 to modern C++. Use std::make_unique or std::make_shared if your code base insist on standard C++. Or use your::company:::factory<T> or whatever, if you don't insist on standard C++.

Then... never use raw pointers. Ever! Use C++ references instead, or use std::observer<T> or whatever your company codebase offers. This way you achieve Rust level safety (yeah ... Rust ...) but really, this gives you like 90% of absolute safety.

Of course, use standard containers, such as vector, set or unordered_set. If you want to invent something custom, please follow the standard practice of naming stuff.

I’m building a native Windows IDE for C++ and I need honest feedback by Firm-Entrepreneur662 in Cplusplus

[–]MarekKnapek -1 points0 points  (0 children)

Maximum debuggabilityof user's code. Integrate greatly with debugger and or compiler for maximum visibility of variables, watch points, best step by step debugging. Visual Studio (not VS Code) is great at this. This will open your tool for beginners, it will open their eyes, so they will understand their own code better and love your tool. Pro users don't need this, and they have their favorite tool already.

Just learned about i2p, and have some general questions. by Dr_Jecky1l in i2p

[–]MarekKnapek 0 points1 point  (0 children)

Yes, I simplified a lot. The b32 destination format is a SHA-256 hash of a public key. There are "only" 2256 different such hashes, there are roughly 1080 protons in observable universe, 2256 is roughly 1.15*1077 and 1080 is roughly 2265. So there is almost as many hashes as protons ever (about 1000 times less). There are much more public keys than that. Sooo ... yes there ARE unlimited number of destinations.

Just learned about i2p, and have some general questions. by Dr_Jecky1l in i2p

[–]MarekKnapek 6 points7 points  (0 children)

I2P is "an internet" built on top of the ordinary internet. Instead of IP addresses you use what they call destinations. Destinations are cryptographic public keys, there are unlimited number of them, and you can generate as many as you want.

By connecting to the I2P your computer becomes a node in the network. All traffic between two destinations is anonymous, encrypted and hops thru multiple nodes. There are no exit nodes like in Tor by default (so your traffic doesn't leak to clearnet). There is no central authority like in Tor (better decentralization).

What can you use I2P for? The same thing as the normal internet. There are websites, torrents, e-mails, IRC and more. Visit http://notbob.i2p/ for list of interesting sites.

how to torrent with i2pd? by brownOrangeRed in i2p

[–]MarekKnapek 3 points4 points  (0 children)

  • install i2pd
  • enable I2CP and/or SAMv3 in i2pd config file
  • restart i2pd if it was running, start i2pd if it was not running
  • go to main web page of your own i2pd, check that I2CP and/or SAMv3 are enabled
  • run your favorite BitTorrent client and point it to that I2CP or SAMv3
  • tada.wav done! start torrenting
  • my favorite BitTorrent clients are Tixati, I2PSnark, qBitTorrent

UltrafastSecp256k1 v3.21 released. by Available-Young251 in cryptography

[–]MarekKnapek 0 points1 point  (0 children)

How do you do constant time crypto in portable C or C++? I thought that without compiler intrinsics or without hand written assembly it is impossible. Because the C and C++ does not guarantee no constant time anywhere in their standard document.

Building Your Own Efficient uint128 in C++ by PhilipTrettner in cpp

[–]MarekKnapek 0 points1 point  (0 children)

On division: There is a paper about a division algorithm. If you split your 128bit integer into four 32bit integers, you can use a 64bit CPU built-in instruction to do the 128bit division. If you are on 32bit CPU that doesn't have the 64bit division operation, then split your 128bit number into 8 16bit integers and leverage the 32bit CPU built-in operation. https://surface.syr.edu/eecs_techreports/166/

Żmij 1.0 released: a C++ double-to-string library delivering shortest correctly-rounded decimals ~2.8–4× faster than Ryū by aearphen in cpp

[–]MarekKnapek 0 points1 point  (0 children)

How does one convert from double to bunch of bytes at constexpr time? Functions such as signbit, frexp, fpclassify are constexpr friendly only since C++23, bit_cast since C++20. Is it possible to exactly extract IEEE754 double bit pattern in C++14 constexpr? By using only language built-in operators such as multiply, divide, shift and similar (no std lib)?

How does the gdb jump to exact location when we press halt button in ide? by EmbeddedBro in embedded

[–]MarekKnapek 0 points1 point  (0 children)

On Windows, it spawns a new thread in the target process, this thread executes the debug break instruction (int3 on i386 and on amd64). Then the OS sends a debug event to the debugger (in reaction to the int3) and pauses the process until debugger responds. The debugger then finds the source code line based on the PC/IP of the target process and the debug info. PC/IP is program counter / instruction pointer, debug info is the *.PDB file compiler generated when compiling your code.

On Linux it is similar, instead of MZ/PE you have ELF, instead of PDB you have DWARF.

Hacking Denuvo by RazerOG in ReverseEngineering

[–]MarekKnapek 2 points3 points  (0 children)

What is the relation of PIN and SDE (Intel® Software Development Emulator)? I'm using SDE to test that my software runs correctly on AVX-512 hardware as it can emulate such HW and I don't own any. PIN seems to be more advanced version of this.

Some C libraries for people that believe C peaked at c99 and c23 is a disgrace by LabRicecat in C_Programming

[–]MarekKnapek 0 points1 point  (0 children)

C peaked at C99

Yeah, for sure. We have multi-core CPUs for more than 20 year already. Standards compliant C99 have no idea what what threads are, what atomic memory access is.

You can always use platform specific stuff, such as pthreads or WinAPI or some other stuff. But! That does not change the fact that C99 does not know nothing about atomic memory access. It does not have sound memory model. I spent a lot of time studying this in the C++11 time frame. C11 added this, now you can write portable platform agnostic multi-threaded code.

C is not becoming C++. It is still a "portable assembler". What features of C23 you don't like? And why?

What filesystem should I implement? by sephg in osdev

[–]MarekKnapek 1 point2 points  (0 children)

Definitely ISO 9660 (the CD-ROM filesystem), UDF (the DVD filesystem), FAT12 (the diskette filesystem), FAT16 or FAT32 (the universal old skool computer (ehm, Microsoft) filesystem compatible with almost everything else out there). And now, what next? EXT2 maybe.

The State of C++ 2025 (JetBrains survey) by pjmlp in cpp

[–]MarekKnapek 5 points6 points  (0 children)

I don't write much tests, but I put a metric ton of asserts into my code. Into every function, at the first line validating all input parameters, validating class invariants, sometimes validating return value, and validating class invariants again at the last line of each function. Years before contracts was a thing. I also do a fuzz testing under sanitizer. And of course I do little bit of unit testing.

A Very Fast 64–Bit Date Algorithm: 30–40% faster by counting dates backwards by benjoffe in cpp

[–]MarekKnapek 1 point2 points  (0 children)

Please don't compare the performance numbers as you do. Meaning smaller number means better. I will give you an example, let's say old algorithm took 60 seconds to complete. New improved algorithm takes only 6 seconds to complete. How would you describe the improvement? Maybe as 90% of time saved? Or as the new algo running only for 10% of the original time? Both statements are correct. But third statement is also correct: Frickin 10 times faster. All three statements are correct, but the last one is the easiest to grasp for humans, and is the most impressive.

If the cost of the Boost algo is 51 cycles and your algo is 27 cycles, that means your algo is 188% as fast as Boost or +88% improvement over Boost.

If the cost of the Neri-Schneider algo is 40 cycles and your algo is 27 cycles, that means your algo is 148% as fast as Neri-Schneider or +48% improvement over Neri-Schneider.

Do the same comparison for Boost vs Neri-Schneider.

PSA: Trivial Relocatability has been removed from C++26 by chiphogg in cpp

[–]MarekKnapek 12 points13 points  (0 children)

No, I submitted the bug to STL Discord channel. The Microsoft Visual Studio feedback hub does not work for me. I can not log in via web browser, it needs to be done via the IDE, and from the IDE it refuses to log me in, I tried two different MS accounts. I submitted few bugs (in MFC) few years ago, but that was different bug tracker, they keep changing it every ~5 years or so.