Ever wondered what computer algorithm gets employed when using Ctrl-F to search for specific words in a page of text?
Continue reading
Category Archives: Strings
Number System Conversions in C++
A posting which I will probably update from time to time that summarizes the conversion functions I encounter in C++. Hope others will find this useful too.
Continue reading
Converting between binary and decimal representations of IEEE 754 floating-point numbers in C++, Java and Python
This post implements a previous post that explains how to convert 32-bit floating point numbers to binary numbers in the IEEE 754 format. What we have is some C++ / Java / Python routines that will allows us to convert a floating point value into it’s equivalent binary counterpart, using the standard IEEE 754 representation consisting of the sign bit, exponent and mantissa (fractional part).
Continue reading
Mapping Words to Line Numbers in Text Files in STL / C++
Following on from the previous post, this example shows an example of how to use an STL multimap to track the line number(s) associated with each word in a text file.
Continue reading
Counting the Number of Words in a Text File in STL / C++
This post aims to illustrate the power of using STL’s associative arrays as a word counter. It reads the entire contents of the text file, word-by-word, and keeps a running total of the number of occurences of each word. All using just a few lines of code, discounting the bits that output the results.
Continue reading
Java Strings: The Basics
One long section of code outlining how to achieve some basic string handling objectives in Java. Currently trying to get to grips with this language after spending far too many years concentrating on C++. Each technique is demonstrated with a code snippet. As with a lot of my other stuff, any new stuff I find useful will get added at a later date:
Continue reading
Some neat examples of C++ String Formatting
Some neat string formatting
A pretty neat snippet found on stackoverflow recently (kudos David Rodriguez), that is worth repeating. I’m gonna start using this. Essentially it is a bit of in-house stream formatting. This class make_string produces an instance of an object derived from ostream, which has an implicit conversion to a std::string: Continue reading