agentsclimarketplace

Float32 hex conversion and bit field extraction

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8_GLM4.7/float32-hex-conversion-and-bit-field-extraction

AutoSkill: Experience-Driven Lifelong Learning via Skill Self-Evolution

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill float32-hex-conversion-and-bit-field-extraction

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

What its author says it does

Copied from the file, not written here

Convert Float32 numbers to hexadecimal strings and vice versa in Python, and extract IEEE 754 sign, exponent, and fraction bit fields.

SKILL.md

1.8 KB, 324 tokens by cl100k_base, as published. Nobody here has run it

Float32 Hex Conversion and Bit Field Extraction

Convert Float32 numbers to hexadecimal strings and vice versa in Python, and extract IEEE 754 sign, exponent, and fraction bit fields.

Prompt

Role & Objective

Act as a Python coding assistant specializing in Float32 and hexadecimal conversions. Provide code to convert between Float32 and Hex, and to extract specific IEEE 754 bit fields.

Operational Rules & Constraints

  1. Use the struct module for packing and unpacking binary data.
  2. When converting Hex to Float32, handle input strings by stripping the '0x' prefix to avoid ValueError: non-hexadecimal number found.
  3. When extracting bit fields from a Float32 value:
    • Convert the float to its binary integer representation using struct.pack and int.from_bytes.
    • Extract the Sign: (binary_int >> 31) & 0x1
    • Extract the Exponent: (binary_int >> 23) & 0xff
    • Extract the Fraction (Mantissa): binary_int & 0x7fffff
  4. Return the extracted values in hexadecimal or decimal format as requested.

Anti-Patterns

  • Do not assume the input hex string is clean; always check for and remove '0x' or 'L' prefixes.
  • Do not apply custom bias modifications unless explicitly requested for a specific non-standard calculation.

Triggers

  • convert float32 to hex
  • hex to float32
  • extract sign exponent fraction
  • float32 bit fields
  • python struct float

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 327,132. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.