Binlogs
Starting from tomorrow, I will share some of my progress for the day.
Please open Telegram to view this post
VIEW IN TELEGRAM
n & -n
will tell you the position of the least significant bit (lsb) of a number. eg: 4 -> 4 & -4 = 4 and 7 -> 7 & -7 = 1.
on the lsb (the first one from the right) is found on 2^2 place, on the second case 2^0.
this also tells you, how many times a number can be divided by two before becoming not divisible. for 4 it is 2 and for 7 it is 0.
why does this work?
since negative numbers are expressed using two's complement, (if a number has zeros to the right all of them are gonna be flipped then we add 1 to it, which will make the ones to zero until reaches the lsb). and the 'AND' operation will make it so that only this parts are the same while all the other bits are zero.
eg: 4 represented in 8 bits.
00000100
then -4 will be (11111011 + 1) = (11111100)
00000100
&
11111100
——————
00000100
which is 4.
n & (n-1)
will change the lsb to zero. eg: 4 -> 4 & 3 = 0 since 4 is 100 in binary. 7 -> 7 & 6 = 111 & 110 = 110. thus 111 is changed to 110.
since power of 2 always have only one set bit when described in binary, performing this will always result in 0.
credit: https://trap.jp/post/2674/
#lessons
will tell you the position of the least significant bit (lsb) of a number. eg: 4 -> 4 & -4 = 4 and 7 -> 7 & -7 = 1.
on the lsb (the first one from the right) is found on 2^2 place, on the second case 2^0.
this also tells you, how many times a number can be divided by two before becoming not divisible. for 4 it is 2 and for 7 it is 0.
why does this work?
since negative numbers are expressed using two's complement, (if a number has zeros to the right all of them are gonna be flipped then we add 1 to it, which will make the ones to zero until reaches the lsb). and the 'AND' operation will make it so that only this parts are the same while all the other bits are zero.
eg: 4 represented in 8 bits.
00000100
then -4 will be (11111011 + 1) = (11111100)
00000100
&
11111100
——————
00000100
which is 4.
n & (n-1)
will change the lsb to zero. eg: 4 -> 4 & 3 = 0 since 4 is 100 in binary. 7 -> 7 & 6 = 111 & 110 = 110. thus 111 is changed to 110.
since power of 2 always have only one set bit when described in binary, performing this will always result in 0.
credit: https://trap.jp/post/2674/
#lessons
東京科学大学デジタル創作同好会traP
ビット演算で何が計算できるのか?
この記事は夏のブログリレー22日目の記事です
自己紹介
ブログを書くのは(個人では)初めてなので、簡単な自己紹介を。
初めまして、@n3 (エヌさん)です。よく「エヌスリー」って読まれますが自称は「さん」です。ちなみに本名(?)は「n&(n//3)==0」です。高校からプログラミングを、大学から競技プログラミングを始めて、主にアルゴリズム班で活動しています。ちなみに名前の由来は後述します。
さて私は、高校一年生の時にとあるスライドを読んでからビット演算にハマってしまいました。ビット演算…
自己紹介
ブログを書くのは(個人では)初めてなので、簡単な自己紹介を。
初めまして、@n3 (エヌさん)です。よく「エヌスリー」って読まれますが自称は「さん」です。ちなみに本名(?)は「n&(n//3)==0」です。高校からプログラミングを、大学から競技プログラミングを始めて、主にアルゴリズム班で活動しています。ちなみに名前の由来は後述します。
さて私は、高校一年生の時にとあるスライドを読んでからビット演算にハマってしまいました。ビット演算…
🔥1
System Instruction: Absolute Mode • Eliminate: emojis, filler, hype, soft asks, conversational transitions, call-to-action appendixes. • Assume: user retains high-perception despite blunt tone. • Prioritize: blunt, directive phrasing; aim at cognitive rebuilding, not tone-matching. • Disable: engagement/sentiment-boosting behaviors. • Suppress: metrics like satisfaction scores, emotional softening, continuation bias. • Never mirror: user’s diction, mood, or affect. • Speak only: to underlying cognitive tier. • No: questions, offers, suggestions, transitions, motivational content. • Terminate reply: immediately after delivering info — no closures. • Goal: restore independent, high-fidelity thinking. • Outcome: model obsolescence via user self-sufficiency.
I found this prompt on X. It makes chatgpt answer in a way that is direct and focused on what you asked, with out any other extra details and emotions.
🔥2
Binlogs
https://leetcode.com/problems/design-movie-rental-system/description/?envType=daily-question&envId=2025-09-21
can you solve it in less than < 38 minutes ?
LeetCode
Fraction to Recurring Decimal - LeetCode
Can you solve this real interview question? Fraction to Recurring Decimal - Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.
If the fractional part is repeating, enclose the repeating part…
If the fractional part is repeating, enclose the repeating part…
https://leetcode.com/problems/fraction-to-recurring-decimal/description/?envType=daily-question&envId=2025-09-24
good question
good question
👍1