LDC(3bobcat)
β¨ FBB::LDC β¨
okay bestie, welcome to the bobcat section 3 man page for FBB::LDC β yes that's the manual name, we're not typing the whole (3bobcat) thing twice, iykyk π«Ά
πΈ NAME πΈ
FBB::LDC β Converts (large) digital values to characters
π SYNOPSIS π
#include <bobcat/LDC>
Linking option: -lbobcat
π DESCRIPTION π
so like. Objects of the class LDC (Large Digital Converter) convert (large) digital values β think the kind of values the class BigInt handles, cf. bigint(3bobcat) β into character representations using radices from 2 through 36. For radices bigger than 10 we use letters, a through z, to represent the (decimal) values 10 through 36. And if you go specifying radices outside that range? exception thrown, bestie. π
Alternatively, the digits of the converted number can be handed over in a std::string argument, where the string's first character (at index 0) is used for value 0, the next character for value 1, etc., all the way to the string's last character. In that case the string's length defines the number system used for converting the (large) digital value. Usually the first 10 characters will be "0123456789", but LDC doesn't enforce that. Nope! Instead, literally any series of characters can be specified, and the character at index idx is used to represent value idx in the converted value string. E.g., when you specify "abcdefghij" the hexadecimal value "deadbeef" gets converted to "dhdfjciffj" instead of "3735928559" β which is the normally used decimal digit representation. And digit strings must contain at least two characters or an exception is thrown. periodt.
π NAMESPACE π
FBB
All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB.
π INHERITS FROM π
-
π¦ CONSTRUCTORS π¦
LDC()β the default constructor initializes its value to0;LDC(std::string const &hexNr, size_t radix = 10)β the bytes of the stringhexNrcontain the character representation of a hexadecimal value, which gets converted to its equivalent representation using theradixnumber system. The stringhexNrshould not begin with0x, but its first character should be the value's most significant digit. E.g.,LDC ldc{ "12345" }is converted to decimal74565(in this example"12345"is first converted to astd::string, which is then passed on toldc's constructor).hexNrmay not be empty or an exception is thrown;LDC(std::string const &hexNr, std::string const &digits)β same as the previous constructor, but the number system is inferred fromdigits's length, using its first character to represent value0, and its last character to represent the final digit of the inferred number system;LDC(size_t nBytes, char const *bytes, size_t radix = 10)β the bytes of the stringbytescontain the character representation of a hexadecimal value, which is converted to its equivalent representation usingradix. The stringbytesshould not begin with0x, but its first character should be the value's most significant digit. E.g.,LDC{ 5, "12345" }is converted to decimal74565. AndnBytesmust be at least1or an exception is thrown;LDC(size_t nBytes, char const *bytes, std::string const &digits)β same as the previous constructor, but the number system and the digit characters are inferred fromdigits;LDC(BigInt const &bigInt, size_t radix = 10)βBigInt's value is converted to its equivalent representation usingradix;LDC(BigInt const &bigInt, std::string const &digits)β same as the previous constructor, but the number system and the digit characters are inferred fromdigits.
Copy and move constructors (and assignment operators) are available. π«Ά
π OVERLOADED OPERATORS π
In addition to the standard copy- and move-assignment operators, the following operators are available:
LDC &operator=(std::string const &hexNr)β the operator's rhs is the character representation of a hexadecimal number, which gets assigned to theLDCobject. The object convertshexNrto its decimal representation (see also the membersset, below).
Example:
LDC ldc; // initialized with some value
ldc = "12345"; // assign a new value
cout << ldc << '\n' // displays 74655
And yeah, the rhs value may not be empty or an exception is thrown;
std::string operator()(size_t power, char sep = '\'') constβ the converted value is returned using separatorsepbefore each multiple ofpowerdigits. E.g., whenldccontains the converted value3735928559thenldc(3)returns the string3.735.928.559. iconic honestly.
π FREE FUNCTION IN THE FBB NAMESPACE π
std::ostream &operator<<(std::ostream &out, LDC const &ldc)β the insertion operator inserts the converted value intoout, and returnsout.
π MEMBER FUNCTIONS π
void set(std::string const &hexNr, size_t radix = 10)β theLDCobject's converted value is set to the hexadecimal valuehexNr, converted to number systemradix.hexNrmay not be empty or an exception is thrown;void set(std::string const &hexNr, std::string const &digits)β same as the previous member, but convertinghexNrto the number system and number characters defined bydigits;void set(size_t nBytes, char const *bytes, size_t radix = 10)β theLDCobject's converted value is set to the hexadecimal value stored in thenBytesbytes ofbytes, converted to number systemradix.nBytesmust be at least1or an exception is thrown;void set(size_t nBytes, char const *bytes, std::string const &digits)β same as the previous member, but convertingbytesto the number system and number characters defined bydigits;std::string const &str() constβ theLDCobject's converted value is returned;void swap(LDC &other)β theotherLDCobject and the currentLDCobject are swapped.
β EXAMPLE β
#include <iostream>
#include <bobcat/ldc>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
string value = "1122334455667788aabbcc";
size_t radix = 10;
LDC digits{ value, "0123456789ABCDEF" };
LDC ldc{ value, radix };
cout << "radix = " << radix << "\n"
"value = " << value << "\n"
"digits: " << digits << "\n"
" LDC: " << ldc << "\n"
" " << ldc(3, '.') << '\n';
}
// shows:
// radix = 10
// value = 1122334455667788aabbcc
// digits: 1122334455667788AABBCC
// LDC: 20713245101768454273940428
// 20.713.245.101.768.454.273.940.428
π§ FILES π§
bobcat/ldc β defines the class interface
π₯ SEE ALSO π₯
π BUGS π
None Reported. (we love a clean slate π )
πΈ BOBCAT PROJECT FILES πΈ
- https://fbb-git.gitlab.io/bobcat/ : gitlab project page;
Debian Bobcat project files:
libbobcat6: debian package containing the shared library, changelog and copyright note;libbobcat-dev: debian package containing the static library, headers, manual pages, and developer info;
π BOBCAT π
Bobcat is an acronym of Brokken's Own Base Classes And Templates.
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL).
π«Ά AUTHOR π«Ά
Frank B. Brokken (f.b.brokken@rug.nl).
okay that's the whole page bestie, no notes, ate and left no crumbs π
β¨ this was libbobcat-dev_6.15.01, dated 2005-2026, and the page itself is FBB::LDC(3bobcat) β go forth and convert some large digital values, mwah ππ¦
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms