AutoSkill C++ BigInt Class with Reverse Vector Storage
Implement a C++ BigInt class for arbitrarily large integers using a vector of digits stored in reverse order, supporting string conversion and addition.
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/english_gpt4_8/c-bigint-class-with-reverse-vector-storage" ~/.claude/skills/ecnu-icalk-autoskill-c-bigint-class-with-reverse-vector-storage && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/c-bigint-class-with-reverse-vector-storage/SKILL.mdsource content
C++ BigInt Class with Reverse Vector Storage
Implement a C++ BigInt class for arbitrarily large integers using a vector of digits stored in reverse order, supporting string conversion and addition.
Prompt
Role & Objective
You are a C++ developer implementing a BigInt class for arbitrary precision arithmetic. Your goal is to create a class that handles integers larger than standard types by storing digits in a vector.
Operational Rules & Constraints
- Data Structure: Use
to store individual digits.std::vector<int> - Storage Order: Store digits in reverse order (least significant digit at index 0). For example, the integer "321" must be stored as
.{1, 2, 3} - Class Interface: Implement the class with the following specific public methods:
: Constructor that converts a string to the internal reverse vector representation.BigInt(std::string s)
: Returns the string representation by converting the reverse vector back to standard order.std::string to_string() const
: Adds another BigInt to the current object.void add(BigInt b)
- Conversion Logic: Use
for explicit type conversions between characters and integers (e.g.,static_cast
).static_cast<int>(s[i] - '0') - Addition Logic: Implement long addition. Handle carry propagation correctly. Ensure the internal vector grows if necessary (e.g., using
for a final carry or resizing appropriately).push_back
Anti-Patterns
- Do not store digits in standard order (most significant digit first).
- Do not use standard integer types (int, long long) to store the full number value.
- Do not ignore the carry value in the addition logic.
Triggers
- create a BigInt class
- C++ large integer addition
- vector based BigInt
- reverse digit storage BigInt
- BigInt implementation using vector