Digit limitation from decimal point in C++

Are you actually trying to round the number, or just change its displayed precision? For the former (truncating the extra digits): or (rounding up/down as appropriate, per jheriko’s answer) For the latter: where the parameter to setprecision() is the maximum number of digits to show after the decimal point.

What is O(log(n!)) and O(n!) and Stirling Approximation

O(n!) isn’t equivalent to O(n^n). It is asymptotically less than O(n^n). O(log(n!)) is equal to O(n log(n)). Here is one way to prove that: Note that by using the log rule log(mn) = log(m) + log(n) we can see that: Proof that O(log(n!)) ⊆ O(n log(n)): Which is less than: So O(log(n!)) is a subset of O(n log(n)) Proof that O(n log(n)) ⊆ O(log(n!)): Which is greater … Read more

How do you switch between python 2 and 3, and vice versa?

Using ‘virtualenv’ you can have different isolated Python environments on a single machine. Also you can switch any-time between the different python interpreter versions. What is virtualenv? A Virtual Environment is an isolated working copy of Python which allows you to work on a specific project without worry of affecting other projects. It enables multiple side-by-side installations … Read more

Error loading MySQLdb module: No module named ‘MySQLdb’

MySQLdb is only for Python 2.x. You can’t install in Python 3.x versions. Now from your question i can see that you are working with Django. In this case you have three alternatives, from Django mysql notes: mysqldb mysqlclient mysql-connect-python This gives to you two alternatives, mysqlclient and mysql-connect-python, The first one requires compilation from extensions … Read more

difference between css height : 100% vs height : auto

height: 100% gives the element 100% height of its parent container. height: auto means the element height will depend upon the height of its children. Consider these examples: height: 100% #innerDiv is going to have height: 50px height: auto #innerDiv is going to have height: 10px

Making LaTeX tables smaller?

As well as \singlespacing mentioned previously to reduce the height of the table, a useful way to reduce the width of the table is to add \tabcolsep=0.11cm before the \begin{tabular} command and take out all the vertical lines between columns. It’s amazing how much space is used up between the columns of text. You could reduce the font size to something … Read more

Remove punctuation from string with Regex

First, please read here for information on regular expressions. It’s worth learning. You can use this: Which means: In the end it reads “replace any character that is not a word character or a space character with nothing.”

C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’

Two errors here: first, you’re trying to declare arrays[63] for storing 64 elements, as you’ve probably confused the size of array (n) with the maximum possible index value (that’s n – 1). So it definitely should be litera[64] and liczba[64]. BTW, you have to change this line too – while (i<=64): otherwise you end up trying to access 65th element. And second, you’re trying … Read more

How do I use StringUtils in Java?

java.lang does not contain a class called StringUtils. Several third-party libs do, such as Apache Commons Lang or the Spring framework. Make sure you have the relevant jar in your project classpath and import the correct class.