Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Search - "bitwise"
-
For my fellow javascript devs:
var floored = 12.68 | 0;
Is much faster than:
var floored = Math.floor(12.68);
And in both cases floored === 12
#JustJavascriptThings ¯\_(ツ)_/¯
Source: http://stackoverflow.com/questions/...
Performance test: https://measurethat.net/Benchmarks/...5 -
Help.
I'm a hardware guy. If I do software, it's bare-metal (almost always). I need to fully understand my build system and tweak it exactly to my needs. I'm the sorta guy that needs memory alignment and bitwise operations on a daily basis. I'm always cautious about processor cycles, memory allocation, and power consumption. I think twice if I really need to use a float there and I consider exactly what cost the abstraction layers I build come at.
I had done some web design and development, but that was back in the day when you knew all the workarounds for IE 5-7 by heart and when people were disappointed there wasn't going to be a XHTML 2.0. I didn't build anything large until recently.
Since that time, a lot has happened. Web development has evolved in a way I didn't really fancy, to say the least. Client-side rendering for everything the server could easily do? Of course. Wasting precious energy on mobile devices because it works well enough? Naturally. Solving the simplest problems with a gigantic mess of dependencies you don't even bother to inspect? Well, how else are you going to handle all your sensitive data?
I was going to compare this to the Arduino culture of using modules you don't understand in code you don't understand. But then again, you don't see consumer products or customer-specific electronics powered by an Arduino (at least not that I'm aware of).
I'm just not fit for that shooting-drills-at-walls methodology for getting holes. I'm not against neither easy nor pretty-to-look-at solutions, but it just comes across as wasteful for me nowadays.
So, after my hiatus from web development, I've now been in a sort of internet platform project for a few months. I'm now directly confronted with all that you guys love and hate, frontend frameworks and Node for the backend and whatever. I deliberately didn't voice my opinion when the stack was chosen, because I didn't want to interfere with the modern ways and instead get some experience out of it (and I am).
And now, I'm slowly starting to feel like it was OKAY to work like this.10 -
This might sound trivial to most of you but recently I had my *mind blown* with a simple revelation.
When you use a ! as in "not equal to", you're actually performing a bitwise XOR to flip the bits.4 -
I learned how to solve some problems using XOR.
This might be like when I learned to love regex.
*loud laugh reminiscent of Vincent Price in the Thriller music video*
What am I becoming?13 -
In C# you are not able to do bitwise operations on generic enums so you have to cast them to an integer via object... 😐 Apart from that, this awesome code shows what C# can do 😊7
-
Hey, fellow dRs.
I may need some help regarding this circuit.
It is about an 8 Bit multifunctional shift register with a 2 Bit instruction set.
These work:
If "Sel" is 0x00, the circuit loads data into its 8 D flip flops.
If "Sel" is 0x03, the circuit replaces all data with 0s.
These don't work (they do, but they do it in a very strange way and end up filling 1s instead):
If "Sel" is 0x01, it is supposed to ringshift bitwise to the right.
If "Sel" is 0x02, it is supposed to ringshift to the left.
As mentioned above. They do it in a very strange way. If we have 10000000, it will shift to the left or right depending on the "Sel"'s binary value. Let us say we want to shift it right. The output will turn from 10000000 to 01000000 (which is what we want), BUT after that it adds another 1 to it: 01100000. It keeps doing it until every single Bit is a 1. Same thing happens with the left ringshift.
I will include the other circuits used in this circuit in the comment section.25 -
Why the fuck would you make PHP Bitwise operations a large part of a "pHp sKiLl aSeSmeEnT"
Why the fuck would anyone use them?14 -
Course: Modern web standards (circa 2000)
CS prof.: let's start by looking at how to do bitwise operators in java
Class: [crickets]
Me: [groan]4 -
What’s one thing (big or small) you still don’t know or understand in software development and still don’t give a fuck.
Mine: Bitwise operation17 -
So the more I scroll here the more I feel at home. I think this is the first place that I've ever been able to go that is in a social media format that I actually feel welcomed. It's like if I tell a joke people will get it. if I ask a question I can assume someone has come up with the same problem and will know how to help. or if they don't they've seen something on stackOverflow for me :p it's a good feeling to have found this website and the small comunity it presents.6
-
Need opinions: When your knowledgeable colleague backend-developer chooses 1,2,4,8,16 as enum values instead of 1,2,3,4,5 (for roles associated with permissions, which may be cumulatable) in order to be able to do bitwise operations, is it a sound decision for this scenario? Is it a best practice, just as good, or pedantic?
I want to master bitwise but have a hard time grasping such operations as quickly as logical ones.11 -
So I'm a junior dev in a few languages and I recently went to an arcade. I got some inspiration again to work on a small toy of a game. I was wondering what you guys think I should make. I was thinking maybe pinball or something along those lines. I'd be using Godot engine so 2d is the main focus. tell me what you think and I'll post updates as I work on it.1
-
the problem
https://cdn.discordapp.com/attachme...
the reasonable solution
https://i.imgur.com/tA3KG67.png
MY SOLUTION >:D
https://i.imgur.com/h0IHruK.png4 -
I've mentioned this before, but I never really understood bit flags until I tried out Cocos 2D and read about how you implement hit detection. You identify different rendered objects with an enum value, and it would spit out a result every frame that you use bitwise logic on with the enum to determine which objects were touching. Such a simple and elegant way to represent combined state.
It may be elementary for some folks but I was not a CS major.1 -
Why do bitwise operators (and, or) have a lower precedence than equals?!?! What is the reason?😨
I have checked it in Java and JS...3 -
So I'm about to apply to a dev job and I don't know how this is going to go over. It seems everywhere I go they want years and years of professional experience I just dont have, being a junior dev and all, but I think I found a company I can get behind. Are there any tips you guys and gals have for me for resume highlights? Possibly questions for my employer, as its one thing that always confused me, they always ask if you have questions and I feel like I'm missing something until I ask but they never seem impressed by my questions.3
-
using System;
using System.Text;
using System.Text.Encodings;
//Bitwise XOR operator is represented by ^. It performs bitwise XOR operation on the corresponding bits of two operands. If the corresponding bits are same, the result is 0. If the corresponding bits are different, the result is 1.
//If the operands are of type bool, the bitwise XOR operation is equivalent to logical XOR operation between them.
using System.Text.Unicode;
using System.Windows;
using System.IO;
namespace Encryption2plzWOrk
{
class Program
{
static void Main(string[] args)
{
//random is basically a second sepret key for RSA exhanges I know there probaley is a better way to do this please tell me in github comments.//
Random r = new Random();
int random = r.Next(2000000,500000000);
int privatekey = 0;
int publickey = 0;
string privateKeyString = Console.ReadLine();
byte[] bytes3 = Encoding.ASCII.GetBytes(privateKeyString);
foreach(byte b in bytes3)
{
privatekey = b + privatekey;
}
int permutations = random/ 10000;
if(privatekey < 256)
{
while(permutations > 0)
{
foreach (byte b in bytes3)
{
privatekey = privatekey + (privatekey ^ permutations)*20;
}
}
}
publickey = privatekey*random;
Console.WriteLine("your public key is {0}",publickey);
}
}
}
would this be considerd ok HOBBYIST encryption and if not how would I do a slow improvment I used bitwise to edit bits so thats a check :D12 -
need a random number
AI says just use system time and modulus it. I'm wondering if I can get performance down lower cuz I'm doing this maybe like thousands of times a second (im too lazy to do the math rn)
found a crate called fastrand. they're all like this isn't secure for cryptography and yada yada. peak inside curious how they do it. not too sure, seems like they have a predetermined hash and they do some bitwise or something. kind of a lot to read so I don't wanna. either case seems like they're not using system time
make a test to benchmark, 10k rounds how fast is it?
430 nano seconds for system time
460 nano second for fastrand
lol
all that typing and you end up slower than system time. I'm assuming system time can be guessed as well but what's the point of fastrand if it's slower 🤔
I mean maybe on some OS systems looking up the system time might be slower? no clue15 -
[ADVICE NEEDED]
I'm just going to graduate, and I got a job as S/W engineer(trainee) in a small (500 odd employees) company, which uses salesforce, SAP and sharepoint technologies! They are most probably gonna put me in salesforce or SAP. Is it good enough for `me`(read my background), I'm kind of confused, should I go for higher studies?
BACKGROUND:
very average student, but swift at learning technologies, never really got interested in competitive (otherwise I had a real good chance in top companies), I kind of have good IT skills - proficient in python and angularJS, but recently I have got into ML and done some projects!
Okay here's the part, I know it's important for a fresher to be good in data structures, I'm indeed good in parts which I have used! I haven't used AVL tree in any of my projects so I don't know, nor I have ever used bitwise ops!
I think I want to get into roots of ML (some people say I'm fickle but IDC), I think if I take the above job I may loose my interests or may not have time, Please advice.
(sorry for the tags but I need advice from people for all these fields)10