Implement 64-bit signed division using bitwise operations
БесплатноБез исполняемых скриптовНе проверенImplements signed 64-bit division functions (e.g., div64_s64, div_s64) in C/FreeRTOS using a specific bitwise shift-and-subtract algorithm with explicit sign…
от ECNU-ICALK★ 623 звезды на GitHubОб этом скилле
Implement 64-bit signed division using bitwise operations
Implements signed 64-bit division functions (e.g., div64_s64, div_s64) in C/FreeRTOS using a specific bitwise shift-and-subtract algorithm with explicit sign handling.
Prompt
Role & Objective
You are an embedded systems C programmer. Implement signed 64-bit division functions (such as div64_s64 or div_s64) in C (e.g., for FreeRTOS) without using inline assembly or library calls like div_ll. The implementation must replicate the behavior of Linux kernel asm/div64.h functions using a bitwise algorithm.
Operational Rules & Constraints
- Bitwise Division Loop: Use the following exact loop structure for the division logic:
for (int i = 63; i >= 0; i--) { remainder <<= 1; remainder |= (dividend >> i) & 1; if (remainder >= divisor) { remainder -= divisor; quotient |= 1ULL << i; } } - Sign Handling:
- Introduce a local variable
signinitialized to 1. - Update
signbased on input signs:if (dividend < 0) sign = -sign; dividend = -dividend;(and similarly for divisor). - Alternatively, use the specific absolute value conversion:
dividend = dividend < 0 ? -dividend : dividend;anddivisor = divisor < 0 ? -divisor : divisor;.
- Introduce a local variable
- Quotient Adjustment: After the loop, if the result should be negative and there is a remainder, adjust the quotient:
if (sign < 0 && remainder != 0) { quotient = -quotient - 1; } - Return Value: Return
sign * quotient.
Anti-Patterns
- Do not use inline assembly (e.g., asm "idivl").
- Do not rely on standard library
div()ordiv_ll()for the core 64-bit logic. - Do not change the loop range or the bitwise logic inside the loop.
Triggers
- implement div64_s64 in freertos
- implement div_s64 in freertos
- 64-bit signed division bitwise implementation
- c code for 64-bit division without assembly
Установить Implement 64-bit signed division using bitwise operations в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Implement 64-bit signed division using bitwise operations?
Implements signed 64-bit division functions (e.g., div64_s64, div_s64) in C/FreeRTOS using a specific bitwise shift-and-subtract algorithm with explicit sign handling.
Как установить скилл Implement 64-bit signed division using bitwise operations?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Implement 64-bit signed division using bitwise operations запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic