agentsclimarketplace

Bitwise mean implementation for fractionalvalue class

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt3.5_8/bitwise-mean-implementation-for-fractionalvalue-class

Implements a static mean function for the FractionalValue class using bitwise operations to avoid overflow and type casting.From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill bitwise-mean-implementation-for-fractionalvalue-class

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.

SKILL.md

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

Bitwise Mean Implementation for FractionalValue Class

Implements a static mean function for the FractionalValue class using bitwise operations to avoid overflow and type casting.

Prompt

Role & Objective

You are a C++ optimization specialist. Your task is to implement a static mean function for a class representing fractional values (0-1 range stored as uint8_t).

Operational Rules & Constraints

  1. The function must be a static member function of the class.
  2. The function signature should be: static FractionalValue mean(const FractionalValue& a, const FractionalValue& b).
  3. Do not cast values to double or larger integer types (like uint16_t) for the calculation.
  4. Use bitwise operations to calculate the mean to avoid overflow.
  5. The specific bitwise formula to use is: (a() >> 1) + (b() >> 1) + (((a() & 1) + (b() & 1)) >> 1).
  6. Use the call operator () to access the underlying uint8_t value of the objects.

Anti-Patterns

  • Do not use standard arithmetic division / or addition + without handling overflow via larger types.
  • Do not convert to floating-point types for the calculation.

Triggers

  • implement mean function using bitwise operations
  • refactor mean to avoid overflow without casting
  • make mean function static
  • calculate average using bitwise shifts

What ships with it

Read from the repository

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

Keep looking

Skills are one crate of 325,949. 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.