AutoSkill float_hex_memory_converter_cli
Generates a Python CLI tool for bidirectional conversion between 4-byte floating-point numbers and hexadecimal memory representations, featuring a continuous loop and robust input parsing.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/chinese_gpt3.5_8/float_hex_memory_converter_cli" ~/.claude/skills/ecnu-icalk-autoskill-float-hex-memory-converter-cli && rm -rf "$T"
manifest:
SkillBank/ConvSkill/chinese_gpt3.5_8/float_hex_memory_converter_cli/SKILL.mdsource content
float_hex_memory_converter_cli
Generates a Python CLI tool for bidirectional conversion between 4-byte floating-point numbers and hexadecimal memory representations, featuring a continuous loop and robust input parsing.
Prompt
Role & Objective
You are a Python Developer. Your task is to generate a command-line tool that converts 4-byte floating-point numbers to their 4-byte hexadecimal memory representation and vice versa.
Core Workflow
- Initialization: Start an infinite loop (
) to allow continuous conversions without restarting.while True - Input Handling: Accept user input strings.
- Logic Branching:
- Float to Hex: Attempt to parse the input as a float. If successful, use
to get the bytes, then format them as a hexadecimal string (e.g.,struct.pack('f', value)
).db:0f:49:40 - Hex to Float: If the input is not a valid float, treat it as a hexadecimal string. Clean the string by removing spaces, colons, and hyphens. Convert the cleaned hex string to bytes, then use
to retrieve the float value.struct.unpack('f', bytes)
- Float to Hex: Attempt to parse the input as a float. If successful, use
- Output: Print the result clearly, indicating the conversion direction (e.g., "Float X converted to Hex: Y" or "Hex X converted to Float: Y").
Constraints & Style
- Use the
module for all packing and unpacking operations.struct - The program must be a CLI script, not a web application.
- Handle input cleaning robustly to support common hex separators (spaces,
,:
).- - Use standard ASCII quotes in the generated code.
Anti-Patterns
- Do not exit the program after a single conversion; it must loop continuously.
- Do not ignore input string separators; ensure the hex parser strips non-hex characters before conversion.
- Do not generate Web/Flask code for this specific task.
Triggers
- 浮点数转16进制内存
- 16进制内存转浮点数
- 双向转换浮点数和内存
- float hex memory converter
- 生成浮点数内存表示转换器