2021-10-26 03:34:27 +08:00
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2022-09-08 08:17:03 +08:00
< html xmlns = "http://www.w3.org/1999/xhtml" lang = "en-US" >
2021-10-26 03:34:27 +08:00
< head >
< meta http-equiv = "Content-Type" content = "text/xhtml;charset=UTF-8" / >
< meta http-equiv = "X-UA-Compatible" content = "IE=11" / >
2023-06-21 05:10:10 +08:00
< meta name = "generator" content = "Doxygen 1.9.7" / >
2021-10-26 03:34:27 +08:00
< meta name = "viewport" content = "width=device-width, initial-scale=1" / >
< title > Algorithms_in_C: conversions/decimal_to_any_base.c File Reference< / title >
< link href = "../../tabs.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../jquery.js" > < / script >
< script type = "text/javascript" src = "../../dynsections.js" > < / script >
< link href = "../../navtree.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../resize.js" > < / script >
< script type = "text/javascript" src = "../../navtreedata.js" > < / script >
< script type = "text/javascript" src = "../../navtree.js" > < / script >
< link href = "../../search/search.css" rel = "stylesheet" type = "text/css" / >
< script type = "text/javascript" src = "../../search/searchdata.js" > < / script >
< script type = "text/javascript" src = "../../search/search.js" > < / script >
< script type = "text/x-mathjax-config" >
MathJax.Hub.Config({
extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
jax: ["input/TeX","output/HTML-CSS"],
});
< / script >
< script type = "text/javascript" async = "async" src = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML/MathJax.js" > < / script >
< link href = "../../doxygen.css" rel = "stylesheet" type = "text/css" / >
< / head >
< body >
< div id = "top" > <!-- do not remove this div, it is closed by doxygen! -->
< div id = "titlearea" >
< table cellspacing = "0" cellpadding = "0" >
< tbody >
2022-01-15 04:11:27 +08:00
< tr id = "projectrow" >
< td id = "projectalign" >
2021-10-26 03:34:27 +08:00
< div id = "projectname" > Algorithms_in_C< span id = "projectnumber" >   1.0.0< / span >
< / div >
< div id = "projectbrief" > Set of algorithms implemented in C.< / div >
< / td >
< / tr >
< / tbody >
< / table >
< / div >
<!-- end header part -->
2023-06-21 05:10:10 +08:00
<!-- Generated by Doxygen 1.9.7 -->
2021-10-26 03:34:27 +08:00
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
2022-09-08 08:17:03 +08:00
var searchBox = new SearchBox("searchBox", "../../search/",'.html');
2021-10-26 03:34:27 +08:00
/* @license-end */
< / script >
< script type = "text/javascript" src = "../../menudata.js" > < / script >
< script type = "text/javascript" src = "../../menu.js" > < / script >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(function() {
initMenu('../../',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
< / script >
< div id = "main-nav" > < / div >
< / div > <!-- top -->
< div id = "side-nav" class = "ui-resizable side-nav-resizable" >
< div id = "nav-tree" >
< div id = "nav-tree-contents" >
< div id = "nav-sync" class = "sync" > < / div >
< / div >
< / div >
< div id = "splitbar" style = "-moz-user-select:none;"
class="ui-resizable-handle">
< / div >
< / div >
< script type = "text/javascript" >
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699& dn=expat.txt MIT */
$(document).ready(function(){initNavTree('d1/dba/decimal__to__any__base_8c.html','../../'); initResizable(); });
/* @license-end */
< / script >
< div id = "doc-content" >
<!-- window showing the filter options -->
< div id = "MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
< / div >
<!-- iframe showing the search results (closed by default) -->
< div id = "MSearchResultsWindow" >
2022-09-08 08:17:03 +08:00
< div id = "MSearchResults" >
< div class = "SRPage" >
< div id = "SRIndex" >
< div id = "SRResults" > < / div >
< div class = "SRStatus" id = "Loading" > Loading...< / div >
< div class = "SRStatus" id = "Searching" > Searching...< / div >
< div class = "SRStatus" id = "NoMatches" > No Matches< / div >
< / div >
< / div >
< / div >
2021-10-26 03:34:27 +08:00
< / div >
< div class = "header" >
< div class = "summary" >
< a href = "#func-members" > Functions< / a > < / div >
< div class = "headertitle" > < div class = "title" > decimal_to_any_base.c File Reference< / div > < / div >
< / div > <!-- header -->
< div class = "contents" >
< p > < a href = "http://codeofthedamned.com/index.php/number-base-conversion" target = "_blank" > Decimal to any-base< / a > is a C function wich convert positive decimal integer to any positive ascii base with the base's alphabet given in input and return it in a dynamically allocated string(recursive way)
< a href = "#details" > More...< / a > < / p >
< div class = "textblock" > < code > #include < stdio.h> < / code > < br / >
< code > #include < string.h> < / code > < br / >
< code > #include < stdint.h> < / code > < br / >
< code > #include < stdbool.h> < / code > < br / >
< code > #include < assert.h> < / code > < br / >
< code > #include < stdlib.h> < / code > < br / >
< / div > < div class = "textblock" > < div class = "dynheader" >
Include dependency graph for decimal_to_any_base.c:< / div >
< div class = "dyncontent" >
2023-06-21 05:10:10 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d8/d26/decimal__to__any__base_8c__incl.svg" width = "526" height = "126" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div >
2021-10-26 03:34:27 +08:00
< / div >
< / div > < table class = "memberdecls" >
< tr class = "heading" > < td colspan = "2" > < h2 class = "groupheader" > < a id = "func-members" name = "func-members" > < / a >
Functions< / h2 > < / td > < / tr >
< tr class = "memitem:ae071f62d704823751bf9a085bf0a1bd7" > < td class = "memItemLeft" align = "right" valign = "top" > bool  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html#ae071f62d704823751bf9a085bf0a1bd7" > isbad_alphabet< / a > (const char *alphabet)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ae071f62d704823751bf9a085bf0a1bd7" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > for IO operations < br / > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "separator:ae071f62d704823751bf9a085bf0a1bd7" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:a899b3a7e0f1fac5a465eac0d4b10d711" > < td class = "memItemLeft" align = "right" valign = "top" > uint64_t  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html#a899b3a7e0f1fac5a465eac0d4b10d711" > converted_len< / a > (uint64_t nb, short base)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:a899b3a7e0f1fac5a465eac0d4b10d711" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Calculate the final length of the converted number. < br / > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "separator:a899b3a7e0f1fac5a465eac0d4b10d711" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:a0c5ccb926a23bc0050f213ba3408e18d" > < td class = "memItemLeft" align = "right" valign = "top" > void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html#a0c5ccb926a23bc0050f213ba3408e18d" > convertion< / a > (uint64_t nb, const char *alphabet, short base, char *converted)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:a0c5ccb926a23bc0050f213ba3408e18d" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Convert positive decimal integer into anybase recursively. < br / > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "separator:a0c5ccb926a23bc0050f213ba3408e18d" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:a3e4a7cfc97a528faa4d6e5741461109c" > < td class = "memItemLeft" align = "right" valign = "top" > char *  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (uint64_t nb, const char *alphabet)< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:a3e4a7cfc97a528faa4d6e5741461109c" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > decimal_to_anybase ensure the validity of the parameters and convert any unsigned integers into any ascii positive base < br / > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "separator:a3e4a7cfc97a528faa4d6e5741461109c" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:aa8dca7b867074164d5f45b0f3851269d" > < td class = "memItemLeft" align = "right" valign = "top" > static void  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html#aa8dca7b867074164d5f45b0f3851269d" > test< / a > ()< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:aa8dca7b867074164d5f45b0f3851269d" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Self-test implementations. < br / > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "separator:aa8dca7b867074164d5f45b0f3851269d" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< tr class = "memitem:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "memItemLeft" align = "right" valign = "top" > int  < / td > < td class = "memItemRight" valign = "bottom" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html#ae66f6b31b5ad750f1fe042a706a4e3d4" > main< / a > ()< / td > < / tr >
2023-01-21 05:44:50 +08:00
< tr class = "memdesc:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "mdescLeft" >   < / td > < td class = "mdescRight" > Main function. < br / > < / td > < / tr >
2021-10-26 03:34:27 +08:00
< tr class = "separator:ae66f6b31b5ad750f1fe042a706a4e3d4" > < td class = "memSeparator" colspan = "2" >   < / td > < / tr >
< / table >
< a name = "details" id = "details" > < / a > < h2 class = "groupheader" > Detailed Description< / h2 >
2023-01-21 05:44:50 +08:00
< div class = "textblock" > < p > < a href = "http://codeofthedamned.com/index.php/number-base-conversion" target = "_blank" > Decimal to any-base< / a > is a C function wich convert positive decimal integer to any positive ascii base with the base's alphabet given in input and return it in a dynamically allocated string(recursive way) < / p >
2021-10-26 03:34:27 +08:00
< dl class = "section author" > < dt > Author< / dt > < dd > < a href = "https://github.com/jucollet972" target = "_blank" > jucollet972< / a > < / dd > < / dl >
< / div > < h2 class = "groupheader" > Function Documentation< / h2 >
< a id = "a899b3a7e0f1fac5a465eac0d4b10d711" name = "a899b3a7e0f1fac5a465eac0d4b10d711" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a899b3a7e0f1fac5a465eac0d4b10d711" > ◆   < / a > < / span > converted_len()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > uint64_t converted_len < / td >
< td > (< / td >
< td class = "paramtype" > uint64_t  < / td >
< td class = "paramname" > < em > nb< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > short  < / td >
< td class = "paramname" > < em > base< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Calculate the final length of the converted number. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > nb< / td > < td > to convert < / td > < / tr >
< tr > < td class = "paramname" > base< / td > < td > calculated from alphabet < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > Converted nb string length < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 42< / span > {< / div >
< div class = "line" > < span class = "lineno" > 43< / span > < span class = "comment" > /* Counting the number of characters translated to the base*/< / span > < / div >
< div class = "line" > < span class = "lineno" > 44< / span > < span class = "keywordflow" > if< / span > (nb > base - 1) {< / div >
< div class = "line" > < span class = "lineno" > 45< / span > < span class = "keywordflow" > return< / span > (< a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a899b3a7e0f1fac5a465eac0d4b10d711" > converted_len< / a > (nb/base, base) + 1);< / div >
< div class = "line" > < span class = "lineno" > 46< / span > }< / div >
< div class = "line" > < span class = "lineno" > 47< / span > < span class = "keywordflow" > return< / span > 1;< / div >
< div class = "line" > < span class = "lineno" > 48< / span > }< / div >
2023-06-21 05:10:10 +08:00
< div class = "ttc" id = "adecimal__to__any__base_8c_html_a899b3a7e0f1fac5a465eac0d4b10d711" > < div class = "ttname" > < a href = "../../d1/dba/decimal__to__any__base_8c.html#a899b3a7e0f1fac5a465eac0d4b10d711" > converted_len< / a > < / div > < div class = "ttdeci" > uint64_t converted_len(uint64_t nb, short base)< / div > < div class = "ttdoc" > Calculate the final length of the converted number.< / div > < div class = "ttdef" > < b > Definition< / b > decimal_to_any_base.c:42< / div > < / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2023-06-21 05:10:10 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d1/dba/decimal__to__any__base_8c_a899b3a7e0f1fac5a465eac0d4b10d711_cgraph.svg" width = "114" height = "60" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div >
2021-10-26 03:34:27 +08:00
< / div >
< / div >
< / div >
< a id = "a0c5ccb926a23bc0050f213ba3408e18d" name = "a0c5ccb926a23bc0050f213ba3408e18d" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a0c5ccb926a23bc0050f213ba3408e18d" > ◆   < / a > < / span > convertion()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > void convertion < / td >
< td > (< / td >
< td class = "paramtype" > uint64_t  < / td >
< td class = "paramname" > < em > nb< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > const char *  < / td >
< td class = "paramname" > < em > alphabet< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > short  < / td >
< td class = "paramname" > < em > base< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > char *  < / td >
< td class = "paramname" > < em > converted< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Convert positive decimal integer into anybase recursively. < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > nb< / td > < td > to convert < / td > < / tr >
< tr > < td class = "paramname" > alphabet< / td > < td > inputed by user used for base convertion < / td > < / tr >
< tr > < td class = "paramname" > base< / td > < td > calculated from alphabet < / td > < / tr >
< tr > < td class = "paramname" > converted< / td > < td > string filled with the convertion's result < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > void < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 58< / span > {< / div >
< div class = "line" > < span class = "lineno" > 59< / span > < span class = "comment" > /* Recursive convertion */< / span > < / div >
< div class = "line" > < span class = "lineno" > 60< / span > *(converted) = *(alphabet + nb%base);< / div >
< div class = "line" > < span class = "lineno" > 61< / span > < span class = "keywordflow" > if< / span > (nb > base - 1) {< / div >
< div class = "line" > < span class = "lineno" > 62< / span > < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a0c5ccb926a23bc0050f213ba3408e18d" > convertion< / a > (nb/base, alphabet, base, --converted);< / div >
< div class = "line" > < span class = "lineno" > 63< / span > }< / div >
< div class = "line" > < span class = "lineno" > 64< / span > }< / div >
2023-06-21 05:10:10 +08:00
< div class = "ttc" id = "adecimal__to__any__base_8c_html_a0c5ccb926a23bc0050f213ba3408e18d" > < div class = "ttname" > < a href = "../../d1/dba/decimal__to__any__base_8c.html#a0c5ccb926a23bc0050f213ba3408e18d" > convertion< / a > < / div > < div class = "ttdeci" > void convertion(uint64_t nb, const char *alphabet, short base, char *converted)< / div > < div class = "ttdoc" > Convert positive decimal integer into anybase recursively.< / div > < div class = "ttdef" > < b > Definition< / b > decimal_to_any_base.c:58< / div > < / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2023-06-21 05:10:10 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d1/dba/decimal__to__any__base_8c_a0c5ccb926a23bc0050f213ba3408e18d_cgraph.svg" width = "92" height = "60" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div >
2021-10-26 03:34:27 +08:00
< / div >
< / div >
< / div >
< a id = "a3e4a7cfc97a528faa4d6e5741461109c" name = "a3e4a7cfc97a528faa4d6e5741461109c" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#a3e4a7cfc97a528faa4d6e5741461109c" > ◆   < / a > < / span > decimal_to_anybase()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > char * decimal_to_anybase < / td >
< td > (< / td >
< td class = "paramtype" > uint64_t  < / td >
< td class = "paramname" > < em > nb< / em > , < / td >
< / tr >
< tr >
< td class = "paramkey" > < / td >
< td > < / td >
< td class = "paramtype" > const char *  < / td >
< td class = "paramname" > < em > alphabet< / em >   < / td >
< / tr >
< tr >
< td > < / td >
< td > )< / td >
< td > < / td > < td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > decimal_to_anybase ensure the validity of the parameters and convert any unsigned integers into any ascii positive base < / p >
< dl class = "params" > < dt > Parameters< / dt > < dd >
< table class = "params" >
< tr > < td class = "paramname" > nb< / td > < td > to convert < / td > < / tr >
< tr > < td class = "paramname" > base's< / td > < td > alphabet < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > nb converted on success < / dd >
< dd >
NULL on error < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 73< / span > {< / div >
< div class = "line" > < span class = "lineno" > 74< / span > < span class = "keywordtype" > char< / span > * converted;< / div >
< div class = "line" > < span class = "lineno" > 75< / span > < / div >
< div class = "line" > < span class = "lineno" > 76< / span > < span class = "comment" > /* Verify that alphabet is valid */< / span > < / div >
< div class = "line" > < span class = "lineno" > 77< / span > < span class = "keywordflow" > if< / span > (< a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#ae071f62d704823751bf9a085bf0a1bd7" > isbad_alphabet< / a > (alphabet)) {< / div >
< div class = "line" > < span class = "lineno" > 78< / span > < span class = "keywordflow" > return< / span > NULL;< / div >
< div class = "line" > < span class = "lineno" > 79< / span > }< / div >
< div class = "line" > < span class = "lineno" > 80< / span > < span class = "comment" > /* Convertion */< / span > < / div >
< div class = "line" > < span class = "lineno" > 81< / span > uint64_t base = strlen(alphabet);< / div >
< div class = "line" > < span class = "lineno" > 82< / span > uint64_t final_len = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a899b3a7e0f1fac5a465eac0d4b10d711" > converted_len< / a > (nb, base);< / div >
< div class = "line" > < span class = "lineno" > 83< / span > converted = < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee" > malloc< / a > (< span class = "keyword" > sizeof< / span > (< span class = "keywordtype" > char< / span > ) * (final_len + 1));< / div >
< div class = "line" > < span class = "lineno" > 84< / span > converted[final_len] = 0;< / div >
< div class = "line" > < span class = "lineno" > 85< / span > < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a0c5ccb926a23bc0050f213ba3408e18d" > convertion< / a > (nb, alphabet, base, converted + final_len - 1);< / div >
< div class = "line" > < span class = "lineno" > 86< / span > < span class = "keywordflow" > return< / span > converted;< / div >
< div class = "line" > < span class = "lineno" > 87< / span > }< / div >
2023-06-21 05:10:10 +08:00
< div class = "ttc" id = "adecimal__to__any__base_8c_html_ae071f62d704823751bf9a085bf0a1bd7" > < div class = "ttname" > < a href = "../../d1/dba/decimal__to__any__base_8c.html#ae071f62d704823751bf9a085bf0a1bd7" > isbad_alphabet< / a > < / div > < div class = "ttdeci" > bool isbad_alphabet(const char *alphabet)< / div > < div class = "ttdoc" > for IO operations< / div > < div class = "ttdef" > < b > Definition< / b > decimal_to_any_base.c:20< / div > < / div >
< div class = "ttc" id = "amalloc__dbg_8h_html_a725f50ecaf1959d96de79b36b4788fee" > < div class = "ttname" > < a href = "../../d2/ddd/malloc__dbg_8h.html#a725f50ecaf1959d96de79b36b4788fee" > malloc< / a > < / div > < div class = "ttdeci" > #define malloc(bytes)< / div > < div class = "ttdoc" > This macro replace the standard malloc function with malloc_dbg.< / div > < div class = "ttdef" > < b > Definition< / b > malloc_dbg.h:18< / div > < / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2023-06-21 05:10:10 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d1/dba/decimal__to__any__base_8c_a3e4a7cfc97a528faa4d6e5741461109c_cgraph.svg" width = "308" height = "183" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div >
2021-10-26 03:34:27 +08:00
< / div >
< / div >
< / div >
< a id = "ae071f62d704823751bf9a085bf0a1bd7" name = "ae071f62d704823751bf9a085bf0a1bd7" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ae071f62d704823751bf9a085bf0a1bd7" > ◆   < / a > < / span > isbad_alphabet()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > bool isbad_alphabet < / td >
< td > (< / td >
< td class = "paramtype" > const char *  < / td >
< td class = "paramname" > < em > alphabet< / em > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > for IO operations < / p >
2023-01-21 05:44:50 +08:00
< p > for strchr and strlen for CPU arch's optimized int types for boolean types for assert for malloc and free< / p >
< p > Checking if alphabet is valid < / p > < dl class = "params" > < dt > Parameters< / dt > < dd >
2021-10-26 03:34:27 +08:00
< table class = "params" >
< tr > < td class = "paramname" > base< / td > < td > alphabet inputed by user < / td > < / tr >
< / table >
< / dd >
< / dl >
< dl class = "section return" > < dt > Returns< / dt > < dd > int64_t as success or not < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 20< / span > {< / div >
< div class = "line" > < span class = "lineno" > 21< / span > uint64_t len = strlen(alphabet);< / div >
< div class = "line" > < span class = "lineno" > 22< / span > < / div >
< div class = "line" > < span class = "lineno" > 23< / span > < span class = "comment" > /* Checking th lenght */< / span > < / div >
< div class = "line" > < span class = "lineno" > 24< / span > < span class = "keywordflow" > if< / span > (len < 2) {< / div >
< div class = "line" > < span class = "lineno" > 25< / span > < span class = "keywordflow" > return< / span > < span class = "keyword" > true< / span > ;< / div >
< div class = "line" > < span class = "lineno" > 26< / span > }< / div >
< div class = "line" > < span class = "lineno" > 27< / span > < span class = "comment" > /* Browse the alphabet */< / span > < / div >
< div class = "line" > < span class = "lineno" > 28< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < len ; i++) {< / div >
< div class = "line" > < span class = "lineno" > 29< / span > < span class = "comment" > /* Searching for duplicates */< / span > < / div >
< div class = "line" > < span class = "lineno" > 30< / span > < span class = "keywordflow" > if< / span > (strchr(alphabet + i + 1, alphabet[i]))< / div >
< div class = "line" > < span class = "lineno" > 31< / span > < span class = "keywordflow" > return< / span > < span class = "keyword" > true< / span > ;< / div >
< div class = "line" > < span class = "lineno" > 32< / span > }< / div >
< div class = "line" > < span class = "lineno" > 33< / span > < span class = "keywordflow" > return< / span > < span class = "keyword" > false< / span > ;< / div >
< div class = "line" > < span class = "lineno" > 34< / span > }< / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment -->
< / div >
< / div >
< a id = "ae66f6b31b5ad750f1fe042a706a4e3d4" name = "ae66f6b31b5ad750f1fe042a706a4e3d4" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#ae66f6b31b5ad750f1fe042a706a4e3d4" > ◆   < / a > < / span > main()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "memname" >
< tr >
< td class = "memname" > int main < / td >
< td > (< / td >
< td class = "paramtype" > void  < / td >
< td class = "paramname" > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Main function. < / p >
< dl class = "section return" > < dt > Returns< / dt > < dd > 0 on exit < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 166< / span > {< / div >
< div class = "line" > < span class = "lineno" > 167< / span > < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#aa8dca7b867074164d5f45b0f3851269d" > test< / a > (); < span class = "comment" > // run self-test implementations< / span > < / div >
< div class = "line" > < span class = "lineno" > 168< / span > < span class = "keywordflow" > return< / span > 0;< / div >
< div class = "line" > < span class = "lineno" > 169< / span > }< / div >
2023-06-21 05:10:10 +08:00
< div class = "ttc" id = "adecimal__to__any__base_8c_html_aa8dca7b867074164d5f45b0f3851269d" > < div class = "ttname" > < a href = "../../d1/dba/decimal__to__any__base_8c.html#aa8dca7b867074164d5f45b0f3851269d" > test< / a > < / div > < div class = "ttdeci" > static void test()< / div > < div class = "ttdoc" > Self-test implementations.< / div > < div class = "ttdef" > < b > Definition< / b > decimal_to_any_base.c:94< / div > < / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2023-06-21 05:10:10 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d1/dba/decimal__to__any__base_8c_ae66f6b31b5ad750f1fe042a706a4e3d4_cgraph.svg" width = "496" height = "183" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div >
2021-10-26 03:34:27 +08:00
< / div >
< / div >
< / div >
< a id = "aa8dca7b867074164d5f45b0f3851269d" name = "aa8dca7b867074164d5f45b0f3851269d" > < / a >
2022-09-08 08:17:03 +08:00
< h2 class = "memtitle" > < span class = "permalink" > < a href = "#aa8dca7b867074164d5f45b0f3851269d" > ◆   < / a > < / span > test()< / h2 >
2021-10-26 03:34:27 +08:00
< div class = "memitem" >
< div class = "memproto" >
< table class = "mlabels" >
< tr >
< td class = "mlabels-left" >
< table class = "memname" >
< tr >
< td class = "memname" > static void test < / td >
< td > (< / td >
< td class = "paramtype" > void  < / td >
< td class = "paramname" > < / td > < td > )< / td >
< td > < / td >
< / tr >
< / table >
< / td >
< td class = "mlabels-right" >
< span class = "mlabels" > < span class = "mlabel" > static< / span > < / span > < / td >
< / tr >
< / table >
< / div > < div class = "memdoc" >
< p > Self-test implementations. < / p >
< dl class = "section return" > < dt > Returns< / dt > < dd > void < / dd > < / dl >
2022-01-15 04:11:27 +08:00
< div class = "fragment" > < div class = "line" > < span class = "lineno" > 95< / span > {< / div >
< div class = "line" > < span class = "lineno" > 96< / span > < span class = "keywordtype" > char< / span > * ret = NULL;< / div >
< div class = "line" > < span class = "lineno" > 97< / span > < span class = "keywordtype" > char< / span > * reference = NULL;< / div >
< div class = "line" > < span class = "lineno" > 98< / span > < / div >
< div class = "line" > < span class = "lineno" > 99< / span > < span class = "comment" > /* min dec*/< / span > < / div >
< div class = "line" > < span class = "lineno" > 100< / span > reference = < span class = "stringliteral" > " 0" < / span > ;< / div >
< div class = "line" > < span class = "lineno" > 101< / span > ret = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (0, < span class = "stringliteral" > " 0123456789" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 102< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < strlen(reference) & & i < strlen(ret); i++) {< / div >
< div class = "line" > < span class = "lineno" > 103< / span > assert(ret[i] == reference[i]);< / div >
< div class = "line" > < span class = "lineno" > 104< / span > }< / div >
< div class = "line" > < span class = "lineno" > 105< / span > < span class = "keywordflow" > if< / span > (ret != NULL) {< / div >
< div class = "line" > < span class = "lineno" > 106< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (ret);< / div >
< div class = "line" > < span class = "lineno" > 107< / span > }< / div >
< div class = "line" > < span class = "lineno" > 108< / span > < / div >
< div class = "line" > < span class = "lineno" > 109< / span > < span class = "comment" > /* max dec*/< / span > < / div >
< div class = "line" > < span class = "lineno" > 110< / span > reference = < span class = "stringliteral" > " 18446744073709551615" < / span > ;< / div >
< div class = "line" > < span class = "lineno" > 111< / span > ret = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (18446744073709551615, < span class = "stringliteral" > " 0123456789" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 112< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < strlen(reference) & & i < strlen(ret); i++) {< / div >
< div class = "line" > < span class = "lineno" > 113< / span > assert(ret[i] == reference[i]);< / div >
< div class = "line" > < span class = "lineno" > 114< / span > }< / div >
< div class = "line" > < span class = "lineno" > 115< / span > < span class = "keywordflow" > if< / span > (ret != NULL) {< / div >
< div class = "line" > < span class = "lineno" > 116< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (ret);< / div >
< div class = "line" > < span class = "lineno" > 117< / span > }< / div >
< div class = "line" > < span class = "lineno" > 118< / span > < / div >
< div class = "line" > < span class = "lineno" > 119< / span > < span class = "comment" > /* negative dec*/< / span > < / div >
< div class = "line" > < span class = "lineno" > 120< / span > reference = < span class = "stringliteral" > " 18446744073709551615" < / span > ;< / div >
< div class = "line" > < span class = "lineno" > 121< / span > ret = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (-1, < span class = "stringliteral" > " 0123456789" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 122< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < strlen(reference) & & i < strlen(ret); i++) {< / div >
< div class = "line" > < span class = "lineno" > 123< / span > assert(ret[i] == reference[i]);< / div >
< div class = "line" > < span class = "lineno" > 124< / span > }< / div >
< div class = "line" > < span class = "lineno" > 125< / span > < span class = "keywordflow" > if< / span > (ret != NULL) {< / div >
< div class = "line" > < span class = "lineno" > 126< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (ret);< / div >
< div class = "line" > < span class = "lineno" > 127< / span > }< / div >
< div class = "line" > < span class = "lineno" > 128< / span > < / div >
< div class = "line" > < span class = "lineno" > 129< / span > < span class = "comment" > /* bin */< / span > < / div >
< div class = "line" > < span class = "lineno" > 130< / span > reference = < span class = "stringliteral" > " 101010" < / span > ;< / div >
< div class = "line" > < span class = "lineno" > 131< / span > ret = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (42, < span class = "stringliteral" > " 01" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 132< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < strlen(reference) & & i < strlen(ret); i++) {< / div >
< div class = "line" > < span class = "lineno" > 133< / span > assert(ret[i] == reference[i]);< / div >
< div class = "line" > < span class = "lineno" > 134< / span > }< / div >
< div class = "line" > < span class = "lineno" > 135< / span > < span class = "keywordflow" > if< / span > (ret != NULL) {< / div >
< div class = "line" > < span class = "lineno" > 136< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (ret);< / div >
< div class = "line" > < span class = "lineno" > 137< / span > }< / div >
< div class = "line" > < span class = "lineno" > 138< / span > < / div >
< div class = "line" > < span class = "lineno" > 139< / span > < span class = "comment" > /* octal */< / span > < / div >
< div class = "line" > < span class = "lineno" > 140< / span > reference = < span class = "stringliteral" > " 52" < / span > ;< / div >
< div class = "line" > < span class = "lineno" > 141< / span > ret = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (42, < span class = "stringliteral" > " 01234567" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 142< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < strlen(reference) & & i < strlen(ret); i++) {< / div >
< div class = "line" > < span class = "lineno" > 143< / span > assert(ret[i] == reference[i]);< / div >
< div class = "line" > < span class = "lineno" > 144< / span > }< / div >
< div class = "line" > < span class = "lineno" > 145< / span > < span class = "keywordflow" > if< / span > (ret != NULL) {< / div >
< div class = "line" > < span class = "lineno" > 146< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (ret);< / div >
< div class = "line" > < span class = "lineno" > 147< / span > }< / div >
< div class = "line" > < span class = "lineno" > 148< / span > < / div >
< div class = "line" > < span class = "lineno" > 149< / span > < span class = "comment" > /* hexa */< / span > < / div >
< div class = "line" > < span class = "lineno" > 150< / span > reference = < span class = "stringliteral" > " 2A" < / span > ;< / div >
< div class = "line" > < span class = "lineno" > 151< / span > ret = < a class = "code hl_function" href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > (42, < span class = "stringliteral" > " 0123456789ABCDEF" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 152< / span > < span class = "keywordflow" > for< / span > (< span class = "keywordtype" > int< / span > i = 0; i < strlen(reference) & & i < strlen(ret); i++) {< / div >
< div class = "line" > < span class = "lineno" > 153< / span > assert(ret[i] == reference[i]);< / div >
< div class = "line" > < span class = "lineno" > 154< / span > }< / div >
< div class = "line" > < span class = "lineno" > 155< / span > < span class = "keywordflow" > if< / span > (ret != NULL) {< / div >
< div class = "line" > < span class = "lineno" > 156< / span > < a class = "code hl_define" href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > (ret);< / div >
< div class = "line" > < span class = "lineno" > 157< / span > }< / div >
< div class = "line" > < span class = "lineno" > 158< / span > printf(< span class = "stringliteral" > " [+] All tests have successfully passed!\n" < / span > );< / div >
< div class = "line" > < span class = "lineno" > 159< / span > }< / div >
2023-06-21 05:10:10 +08:00
< div class = "ttc" id = "adecimal__to__any__base_8c_html_a3e4a7cfc97a528faa4d6e5741461109c" > < div class = "ttname" > < a href = "../../d1/dba/decimal__to__any__base_8c.html#a3e4a7cfc97a528faa4d6e5741461109c" > decimal_to_anybase< / a > < / div > < div class = "ttdeci" > char * decimal_to_anybase(uint64_t nb, const char *alphabet)< / div > < div class = "ttdoc" > decimal_to_anybase ensure the validity of the parameters and convert any unsigned integers into any a...< / div > < div class = "ttdef" > < b > Definition< / b > decimal_to_any_base.c:73< / div > < / div >
< div class = "ttc" id = "amalloc__dbg_8h_html_a9cc854374299a1dd933bf62029761768" > < div class = "ttname" > < a href = "../../d2/ddd/malloc__dbg_8h.html#a9cc854374299a1dd933bf62029761768" > free< / a > < / div > < div class = "ttdeci" > #define free(ptr)< / div > < div class = "ttdoc" > This macro replace the standard free function with free_dbg.< / div > < div class = "ttdef" > < b > Definition< / b > malloc_dbg.h:26< / div > < / div >
2021-10-26 03:34:27 +08:00
< / div > <!-- fragment --> < div class = "dynheader" >
Here is the call graph for this function:< / div >
< div class = "dyncontent" >
2023-06-21 05:10:10 +08:00
< div class = "center" > < iframe scrolling = "no" frameborder = "0" src = "../../d1/dba/decimal__to__any__base_8c_aa8dca7b867074164d5f45b0f3851269d_cgraph.svg" width = "399" height = "183" > < p > < b > This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.< / b > < / p > < / iframe > < / div >
2021-10-26 03:34:27 +08:00
< / div >
< / div >
< / div >
< / div > <!-- contents -->
< / div > <!-- doc - content -->
<!-- start footer part -->
< div id = "nav-path" class = "navpath" > <!-- id is needed for treeview function! -->
< ul >
< li class = "navelem" > < a class = "el" href = "../../dir_9babc524d57e25f3d9f4179cabc3599e.html" > conversions< / a > < / li > < li class = "navelem" > < a class = "el" href = "../../d1/dba/decimal__to__any__base_8c.html" > decimal_to_any_base.c< / a > < / li >
2023-06-21 05:10:10 +08:00
< li class = "footer" > Generated by < a href = "https://www.doxygen.org/index.html" > < img class = "footer" src = "../../doxygen.svg" width = "104" height = "31" alt = "doxygen" / > < / a > 1.9.7 < / li >
2021-10-26 03:34:27 +08:00
< / ul >
< / div >
< / body >
< / html >