ℹ️ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.4 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://stackoverflow.com/questions/11243272/error-correcting-codes |
| Last Crawled | 2026-03-27 15:30:47 (12 days ago) |
| First Indexed | not set |
| HTTP Status Code | 200 |
| Meta Title | c++ - Error correcting codes - Stack Overflow |
| Meta Description | null |
| Meta Canonical | null |
| Boilerpipe Text | Reed-Solomon encoders are described in the form RS(CAPACITY,PAYLOAD). The capacity is always 2^SYMBOL-1, where SYMBOL is the number of bits in each Reed-Solomon symbol. Quite often, this SYMBOL size is 8 bits (a normal byte). It can typically be anything from 3 to 16 bits. For an 8-bit symbol, the Reed-Solomon encoder will be named RS(255,PAYLOAD).
The PAYLOAD is the number of non-parity symbols. If you want 4 parity symbols, you would specify RS(255,251).
To effectively correct errors in your data block, you must first package the data as symbols (groups of bits, quite often just 8-bit bytes). Your goal is to try to arrange (if possible) for any errors to be clustered into the smallest number of symbols possible.
For example, if an error occurs on average every 8 bits, then an 8-bit symbol will not be appropriate; pretty much every symbol will have an error! You might go for 4-bit symbols and use an RS(15,11) codec -- for up to 11 4-bit symbols at a time, producing 4 parity symbols per block. The smaller the symbol size, the lower the CAPACITY (eg. for a SYMBOL size of 4 bits, 2^4-1 == 15 symbol CAPACITY).
But typically, you would use 8-bit symbols. If you have a more realistic error rate of, say, 10% of your 8-bit symbols being erroneous, then you might use an RS(255,205) -- 50 parity symbols per 255 symbol Reed-Solomon "codeword", with a maximum PAYLOAD of 205 bytes. This gives us ~25% parity, allowing us to correct a codeword containing up to ~12.5% errors.
Using
https://github.com/pjkundert/ezpwd-reed-solomon
's c++/ezpwd/rs Reed-Solomon API, you would specify this as:
#include <ezpwd/rs>
...
ezpwd::RS<255,205> rscodec;
Put your data in a std::string (it can handle raw 8-bit binary data just fine) or a std::vector and call the API, adding the 50 symbols of parity:
std::string data;
// ... fill data with a fixed size block, up to 205 bytes
rscodec.encode( data );
Send your data, and later on, after you receive the data+parity, recover the original data (and discard the 50 parity symbols):
int corrected = rscodec.decode( data );
If the data could be recovered, the number of symbols corrected will be returned, or -1 if the Reed-Solomon codeword contained too many errors.
Enjoy! |
| Markdown | [Skip to main content](https://stackoverflow.com/questions/11243272/error-correcting-codes#content)
1. [About](https://stackoverflow.co/)
2. Products
3. [For Teams](https://stackoverflow.co/internal/)
4. Try new site Try BETA
1. [Stack Internal Implement a knowledge platform layer to power your enterprise and AI tools.](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-for-teams)
2. [Stack Data Licensing Get access to top-class technical expertise with trusted & attributed content.](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=overflow-api)
3. [Stack Ads Connect your brand to the world’s most trusted technologist communities.](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=stack-overflow-advertising)
4. [Releases Keep up-to-date on features we add to Stack Overflow and Stack Internal.](https://stackoverflow.blog/releases/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=releases)
5. [About the company](https://stackoverflow.co/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=about-the-company) [Visit the blog](https://stackoverflow.blog/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=top-nav&utm_content=blog)
1. ### [current community](https://stackoverflow.com/)
- [Stack Overflow](https://stackoverflow.com/)
[help](https://stackoverflow.com/help) [chat](https://chat.stackoverflow.com/?tab=explore)
- [Meta Stack Overflow](https://meta.stackoverflow.com/)
### your communities
[Sign up](https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11243272%2Ferror-correcting-codes) or [log in](https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11243272%2Ferror-correcting-codes) to customize your list.
### [more stack exchange communities](https://stackexchange.com/sites)
[company blog](https://stackoverflow.blog/)
2. [Log in](https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11243272%2Ferror-correcting-codes)
3. [Sign up](https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F11243272%2Ferror-correcting-codes)
1. 1. [Home](https://stackoverflow.com/)
2. [Questions](https://stackoverflow.com/questions)
3. [AI Assist](https://stackoverflow.com/ai-assist)
4. [Tags](https://stackoverflow.com/tags)
5. [Challenges](https://stackoverflow.com/beta/challenges)
6. [Chat](https://chat.stackoverflow.com/?tab=explore)
7. [Articles](https://stackoverflow.blog/contributed?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=so-blog&utm_content=experiment-articles)
8. [Users](https://stackoverflow.com/users)
9. [Companies](https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav)
10. [Collectives]()
11. Communities for your favorite technologies. [Explore all Collectives](https://stackoverflow.com/collectives-all)
2. Stack Internal
Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work.
[Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams)
3. [Stack Internal]()
4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact)
##### Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
[Learn more about Collectives](https://stackoverflow.com/collectives)
**Stack Internal**
Knowledge at work
Bring the best of human thought and AI automation together at your work.
[Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover)
# [Error correcting codes \[closed\]](https://stackoverflow.com/questions/11243272/error-correcting-codes)
[Ask Question](https://stackoverflow.com/questions/ask)
Asked
13 years, 9 months ago
Modified [2 months ago](https://stackoverflow.com/questions/11243272/error-correcting-codes?lastactivity "2026-01-05 16:51:18Z")
Viewed 16k times
4
**Closed**. This question needs to be more [focused](https://stackoverflow.com/help/closed-questions). It is not currently accepting answers.
***
**Want to improve this question?** Guide the asker to update the question so it focuses on a single, specific problem. Narrowing the question will help others answer the question concisely. You may [edit the question](https://stackoverflow.com/posts/11243272/edit) if you feel you can improve it yourself. If edited, the question will be reviewed and might be reopened.
Closed 3 months ago.
[Improve this question](https://stackoverflow.com/posts/11243272/edit)
I need to use an error correcting technique on short messages (between 100 and 200 bits). Space available to add the redundant bits is constrained to 20-50%.
I will have to implement the coding and decoding in C/C++. So it needs to be either open sourced or sufficiently easy to program. (I have had some experience in the past with decoding algorithms - they are dreadful!)
Can anyone advise of a suitable error code to use (with relevant parameters) ?
- [c++](https://stackoverflow.com/questions/tagged/c%2B%2B "show questions tagged 'c++'")
- [c](https://stackoverflow.com/questions/tagged/c "show questions tagged 'c'")
- [error-correction](https://stackoverflow.com/questions/tagged/error-correction "show questions tagged 'error-correction'")
[Share](https://stackoverflow.com/q/11243272 "Short permalink to this question")
[Improve this question](https://stackoverflow.com/posts/11243272/edit)
Follow
[edited Jun 28, 2012 at 11:07](https://stackoverflow.com/posts/11243272/revisions "show all edits to this post")
[](https://stackoverflow.com/users/1131467/andrew-tomazos)
[Andrew Tomazos](https://stackoverflow.com/users/1131467/andrew-tomazos)
69\.5k4747 gold badges210210 silver badges349349 bronze badges
asked Jun 28, 2012 at 11:05
user1196549
1
- 1
what kind of errors do you expect? Bursts where larger, continuous sections of data are defect or single bit flips spread over the whole region? Is it sufficient to just detect the errors or do you need to correct them?
Tobias Langner
– [Tobias Langner](https://stackoverflow.com/users/79996/tobias-langner "10,868 reputation")
2012-06-28 11:22:07 +00:00
Commented Jun 28, 2012 at 11:22
[Add a comment](https://stackoverflow.com/questions/11243272/error-correcting-codes "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \|
## 2 Answers 2
Sorted by:
[Reset to default](https://stackoverflow.com/questions/11243272/error-correcting-codes?answertab=scoredesc#tab-top)
11
Take a look at Reed Solomon error correction.
Sample implementation in C++ is available [here](http://www.drdobbs.com/cpp/reed-solomon-error-correction/184410107).
For a different option look [here](http://www.eccpage.com/) - see item \#11
EDIT: If you want a commercial library - <http://www.schifra.com/faq.html>
[Share](https://stackoverflow.com/a/11243400 "Short permalink to this answer")
[Improve this answer](https://stackoverflow.com/posts/11243400/edit)
Follow
[edited Jun 28, 2012 at 11:20](https://stackoverflow.com/posts/11243400/revisions "show all edits to this post")
answered Jun 28, 2012 at 11:13
[](https://stackoverflow.com/users/782997/kjp)
[kjp](https://stackoverflow.com/users/782997/kjp)
3,1462525 silver badges3131 bronze badges
Sign up to request clarification or add additional context in comments.
## 1 Comment
Add a comment
[](https://stackoverflow.com/users/147192/matthieu-m)
Matthieu M.
[Matthieu M.](https://stackoverflow.com/users/147192/matthieu-m)
[Over a year ago](https://stackoverflow.com/questions/11243272/error-correcting-codes#comment14773779_11243400)
I successfully used Reed Solomon in the past, even the C API is simple enough.
2012-06-28T11:20:11.183Z+00:00
0
Reply
- Copy link
3
Reed-Solomon encoders are described in the form RS(CAPACITY,PAYLOAD). The capacity is always 2^SYMBOL-1, where SYMBOL is the number of bits in each Reed-Solomon symbol. Quite often, this SYMBOL size is 8 bits (a normal byte). It can typically be anything from 3 to 16 bits. For an 8-bit symbol, the Reed-Solomon encoder will be named RS(255,PAYLOAD).
The PAYLOAD is the number of non-parity symbols. If you want 4 parity symbols, you would specify RS(255,251).
To effectively correct errors in your data block, you must first package the data as symbols (groups of bits, quite often just 8-bit bytes). Your goal is to try to arrange (if possible) for any errors to be clustered into the smallest number of symbols possible.
For example, if an error occurs on average every 8 bits, then an 8-bit symbol will not be appropriate; pretty much every symbol will have an error! You might go for 4-bit symbols and use an RS(15,11) codec -- for up to 11 4-bit symbols at a time, producing 4 parity symbols per block. The smaller the symbol size, the lower the CAPACITY (eg. for a SYMBOL size of 4 bits, 2^4-1 == 15 symbol CAPACITY).
But typically, you would use 8-bit symbols. If you have a more realistic error rate of, say, 10% of your 8-bit symbols being erroneous, then you might use an RS(255,205) -- 50 parity symbols per 255 symbol Reed-Solomon "codeword", with a maximum PAYLOAD of 205 bytes. This gives us ~25% parity, allowing us to correct a codeword containing up to ~12.5% errors.
Using <https://github.com/pjkundert/ezpwd-reed-solomon>'s c++/ezpwd/rs Reed-Solomon API, you would specify this as:
```
#include <ezpwd/rs>
...
ezpwd::RS<255,205> rscodec;
```
Put your data in a std::string (it can handle raw 8-bit binary data just fine) or a std::vector and call the API, adding the 50 symbols of parity:
```
std::string data;
// ... fill data with a fixed size block, up to 205 bytes
rscodec.encode( data );
```
Send your data, and later on, after you receive the data+parity, recover the original data (and discard the 50 parity symbols):
```
int corrected = rscodec.decode( data );
```
If the data could be recovered, the number of symbols corrected will be returned, or -1 if the Reed-Solomon codeword contained too many errors.
Enjoy\!
[Share](https://stackoverflow.com/a/28422478 "Short permalink to this answer")
[Improve this answer](https://stackoverflow.com/posts/28422478/edit)
Follow
[edited May 25, 2015 at 14:27](https://stackoverflow.com/posts/28422478/revisions "show all edits to this post")
answered Feb 10, 2015 at 1:15
[](https://stackoverflow.com/users/602053/pjkundert)
[pjkundert](https://stackoverflow.com/users/602053/pjkundert)
49944 silver badges88 bronze badges
## 1 Comment
Add a comment
user1196549
user1196549
[Over a year ago](https://stackoverflow.com/questions/11243272/error-correcting-codes#comment45185547_28422478)
Thanks for caring to answer. This question is two years old. Since then, I have developed my own RS corrector, using the Euclidean algorithm (in comparison the encoder is a child's play). Admittedly, that was a rather painful experience as this theory really is rocket science, and there is a nasty devil in the details. But in the end it is quite rewarding to master these mysteries.
2015-02-10T08:16:12.963Z+00:00
0
Reply
- Copy link
- The Overflow Blog
- [Prevent agentic identity theft](https://stackoverflow.blog/2026/03/27/prevent-agentic-identity-theft/)
- [Building shared coding guidelines for AI (and people too)](https://stackoverflow.blog/2026/03/26/coding-guidelines-for-ai-agents-and-people-too/)
- Featured on Meta
- [I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s...](https://meta.stackoverflow.com/questions/438369/i-m-jody-the-chief-product-and-technology-officer-at-stack-overflow-let-s-talk "I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s talk about the site redesign")
- [Release notes and bug fixes for beta.stackoverflow.com](https://meta.stackoverflow.com/questions/438499/release-notes-and-bug-fixes-for-beta-stackoverflow-com)
- [Policy: Generative AI (e.g., ChatGPT) is banned](https://meta.stackoverflow.com/questions/421831/policy-generative-ai-e-g-chatgpt-is-banned)
#### Related
[198](https://stackoverflow.com/questions/385975/error-handling-in-c-code "Question score (upvotes - downvotes)")
[Error handling in C code](https://stackoverflow.com/questions/385975/error-handling-in-c-code)
[6](https://stackoverflow.com/questions/2755697/error-handling-strategies-in-c "Question score (upvotes - downvotes)")
[error handling strategies in C?](https://stackoverflow.com/questions/2755697/error-handling-strategies-in-c)
[1](https://stackoverflow.com/questions/3464838/finding-errors-in-a-given-c-code "Question score (upvotes - downvotes)")
[finding errors in a given c code](https://stackoverflow.com/questions/3464838/finding-errors-in-a-given-c-code)
[0](https://stackoverflow.com/questions/3824921/error-handling-in-c "Question score (upvotes - downvotes)")
[Error handling in C++](https://stackoverflow.com/questions/3824921/error-handling-in-c)
[0](https://stackoverflow.com/questions/11741808/error-code-handling "Question score (upvotes - downvotes)")
[Error Code Handling](https://stackoverflow.com/questions/11741808/error-code-handling)
[1](https://stackoverflow.com/questions/20570708/concise-and-non-obtrusive-error-handling-in-c "Question score (upvotes - downvotes)")
[Concise and non-obtrusive error handling in C](https://stackoverflow.com/questions/20570708/concise-and-non-obtrusive-error-handling-in-c)
[0](https://stackoverflow.com/questions/27940747/pseudo-code-program-for-handling-errors "Question score (upvotes - downvotes)")
[Pseudo-code program for handling errors](https://stackoverflow.com/questions/27940747/pseudo-code-program-for-handling-errors)
[0](https://stackoverflow.com/questions/28846804/error-checking-in-c "Question score (upvotes - downvotes)")
[Error Checking In C](https://stackoverflow.com/questions/28846804/error-checking-in-c)
[0](https://stackoverflow.com/questions/33559303/hamming-code-error-detection-correction "Question score (upvotes - downvotes)")
[Hamming Code - Error Detection & Correction](https://stackoverflow.com/questions/33559303/hamming-code-error-detection-correction)
[0](https://stackoverflow.com/questions/46419274/how-do-i-design-error-codes-in-c "Question score (upvotes - downvotes)")
[How do I design error codes in c++?](https://stackoverflow.com/questions/46419274/how-do-i-design-error-codes-in-c)
#### [Hot Network Questions](https://stackexchange.com/questions?tab=hot)
- [Has Theology and Contemporary Hermeneutics Managed to Change the Actual Meaning of αγαπας/ἀγαπάω over the last 2000 years?](https://hermeneutics.stackexchange.com/questions/115532/has-theology-and-contemporary-hermeneutics-managed-to-change-the-actual-meaning)
- [Is isolation needed in purely battery-powered circuits?](https://electronics.stackexchange.com/questions/767348/is-isolation-needed-in-purely-battery-powered-circuits)
- [Acoustically speaking, are Norse "hunting horns" going to sound similar to Jewish shofars?](https://music.stackexchange.com/questions/143408/acoustically-speaking-are-norse-hunting-horns-going-to-sound-similar-to-jewis)
- [Got called back for a job, but haven't received the follow-up call](https://workplace.stackexchange.com/questions/203310/got-called-back-for-a-job-but-havent-received-the-follow-up-call)
- [How long will it take the remaining cleaners?](https://math.stackexchange.com/questions/5130333/how-long-will-it-take-the-remaining-cleaners)
- [Blood of Chayot](https://judaism.stackexchange.com/questions/155619/blood-of-chayot)
- [References on computability and intuitionism](https://mathoverflow.net/questions/509560/references-on-computability-and-intuitionism)
- [Why paraglider canopy swings backwards when entering an updraft?](https://aviation.stackexchange.com/questions/115085/why-paraglider-canopy-swings-backwards-when-entering-an-updraft)
- [Doubt in Lagrangian formalism](https://physics.stackexchange.com/questions/870577/doubt-in-lagrangian-formalism)
- [Finding maximum source current before resistors exceed power rating (where is my mistake?)](https://electronics.stackexchange.com/questions/767365/finding-maximum-source-current-before-resistors-exceed-power-rating-where-is-my)
- [Did J.K. Rowling retcon the ability of house elves to apparate in Hogwarts?](https://scifi.stackexchange.com/questions/303818/did-j-k-rowling-retcon-the-ability-of-house-elves-to-apparate-in-hogwarts)
- [What is the physics behind how welding works?](https://physics.stackexchange.com/questions/870560/what-is-the-physics-behind-how-welding-works)
- [Nonautonomous Lie derivative](https://mathoverflow.net/questions/509562/nonautonomous-lie-derivative)
- [A Holiday to Remember... or Forget?! (Meta-puzzle)](https://puzzling.stackexchange.com/questions/137502/a-holiday-to-remember-or-forget-meta-puzzle)
- [Colleague doesn't work on any task unless request specifically comes from the boss](https://workplace.stackexchange.com/questions/203302/colleague-doesnt-work-on-any-task-unless-request-specifically-comes-from-the-bo)
- [What is the formula for the input resistance of a BJT in a voltage divisor bias configuration?](https://electronics.stackexchange.com/questions/767428/what-is-the-formula-for-the-input-resistance-of-a-bjt-in-a-voltage-divisor-bias)
- [Which angel saved Shadrach, Mishach, and Abed-nego?](https://judaism.stackexchange.com/questions/155616/which-angel-saved-shadrach-mishach-and-abed-nego)
- [The origin of the potential in crystal](https://physics.stackexchange.com/questions/870578/the-origin-of-the-potential-in-crystal)
- [How can I restore the VS Code color theme after update 1.113?](https://stackoverflow.com/questions/79914612/how-can-i-restore-the-vs-code-color-theme-after-update-1-113)
- [In Switch, is "value1" really only evaluated if "form1" matches "expr"?](https://mathematica.stackexchange.com/questions/319091/in-switch-is-value1-really-only-evaluated-if-form1-matches-expr)
- [Which prepositions can be placed before the word « où » ?](https://french.stackexchange.com/questions/58820/which-prepositions-can-be-placed-before-the-word-o%C3%B9)
- [If I installed both GOG and Steam No Man's Sky, would their universes be separate?](https://gaming.stackexchange.com/questions/418257/if-i-installed-both-gog-and-steam-no-mans-sky-would-their-universes-be-separat)
- [Online tool to write LaTeX formulas on a non-editable PDF](https://tex.stackexchange.com/questions/761233/online-tool-to-write-latex-formulas-on-a-non-editable-pdf)
- [What does "world" mean in "God was reconciling the world to himself"? 2 Corinthians 5:19](https://hermeneutics.stackexchange.com/questions/115537/what-does-world-mean-in-god-was-reconciling-the-world-to-himself-2-corinthi)
[more hot questions](https://stackoverflow.com/questions/11243272/error-correcting-codes)

default
##### [Stack Overflow](https://stackoverflow.com/)
- [Questions](https://stackoverflow.com/questions)
- [Help](https://stackoverflow.com/help)
- [Chat](https://chat.stackoverflow.com/?tab=explore)
##### [Business](https://stackoverflow.co/)
- [Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=teams)
- [Stack Data Licensing](https://stackoverflow.co/data-licensing/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=data-licensing)
- [Stack Ads](https://stackoverflow.co/advertising/?utm_medium=referral&utm_source=stackoverflow-community&utm_campaign=footer&utm_content=advertising)
##### [Company](https://stackoverflow.co/)
- [About](https://stackoverflow.co/)
- [Press](https://stackoverflow.co/company/press/)
- [Work Here](https://stackoverflow.co/company/work-here/)
- [Legal](https://stackoverflow.com/legal)
- [Privacy Policy](https://stackoverflow.com/legal/privacy-policy)
- [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public)
- [Contact Us](https://stackoverflow.com/contact)
- Cookie Settings
- [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy)
##### [Stack Exchange Network](https://stackexchange.com/)
- [Technology](https://stackexchange.com/sites#technology)
- [Culture & recreation](https://stackexchange.com/sites#culturerecreation)
- [Life & arts](https://stackexchange.com/sites#lifearts)
- [Science](https://stackexchange.com/sites#science)
- [Professional](https://stackexchange.com/sites#professional)
- [Business](https://stackexchange.com/sites#business)
- [API](https://api.stackexchange.com/)
- [Data](https://data.stackexchange.com/)
- [Blog](https://stackoverflow.blog/?blb=1)
- [Facebook](https://www.facebook.com/officialstackoverflow/)
- [Twitter](https://twitter.com/stackoverflow)
- [LinkedIn](https://linkedin.com/company/stack-overflow)
- [Instagram](https://www.instagram.com/thestackoverflow)
Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.3.27.41551 |
| Readable Markdown | Reed-Solomon encoders are described in the form RS(CAPACITY,PAYLOAD). The capacity is always 2^SYMBOL-1, where SYMBOL is the number of bits in each Reed-Solomon symbol. Quite often, this SYMBOL size is 8 bits (a normal byte). It can typically be anything from 3 to 16 bits. For an 8-bit symbol, the Reed-Solomon encoder will be named RS(255,PAYLOAD).
The PAYLOAD is the number of non-parity symbols. If you want 4 parity symbols, you would specify RS(255,251).
To effectively correct errors in your data block, you must first package the data as symbols (groups of bits, quite often just 8-bit bytes). Your goal is to try to arrange (if possible) for any errors to be clustered into the smallest number of symbols possible.
For example, if an error occurs on average every 8 bits, then an 8-bit symbol will not be appropriate; pretty much every symbol will have an error! You might go for 4-bit symbols and use an RS(15,11) codec -- for up to 11 4-bit symbols at a time, producing 4 parity symbols per block. The smaller the symbol size, the lower the CAPACITY (eg. for a SYMBOL size of 4 bits, 2^4-1 == 15 symbol CAPACITY).
But typically, you would use 8-bit symbols. If you have a more realistic error rate of, say, 10% of your 8-bit symbols being erroneous, then you might use an RS(255,205) -- 50 parity symbols per 255 symbol Reed-Solomon "codeword", with a maximum PAYLOAD of 205 bytes. This gives us ~25% parity, allowing us to correct a codeword containing up to ~12.5% errors.
Using <https://github.com/pjkundert/ezpwd-reed-solomon>'s c++/ezpwd/rs Reed-Solomon API, you would specify this as:
```
#include <ezpwd/rs>
...
ezpwd::RS<255,205> rscodec;
```
Put your data in a std::string (it can handle raw 8-bit binary data just fine) or a std::vector and call the API, adding the 50 symbols of parity:
```
std::string data;
// ... fill data with a fixed size block, up to 205 bytes
rscodec.encode( data );
```
Send your data, and later on, after you receive the data+parity, recover the original data (and discard the 50 parity symbols):
```
int corrected = rscodec.decode( data );
```
If the data could be recovered, the number of symbols corrected will be returned, or -1 if the Reed-Solomon codeword contained too many errors.
Enjoy\! |
| Shard | 169 (laksa) |
| Root Hash | 714406497480128969 |
| Unparsed URL | com,stackoverflow!/questions/11243272/error-correcting-codes s443 |