I'm writing an algorithm for plotting mathematical functions. I'm new to C++ and programming in general and thus do not know how to implement this properly.  In order to do this, I naively plot the points satisfying the mathematical condition into a bitmap(ppm file) but when I do this and plot a parabola(y*y =4*a*x), only a few points are plotted in the graph. the coordinate axes and straight lines(y=mx+c) are rendered fine.  Here's my code: I draw to a ppm file  int main() {      int width = 512;     int height = 512;     std::ofstream ofs("plot.ppm", std::ios::out);     ofs &lt;&lt; "P3\n" &lt;&lt; width &lt;&lt; " " &lt;&lt; height &lt;&lt; "\n255\n";     for (int h = 0;h&lt; height;h++) {         for (int w = 0; w &lt; width; w++) {             vec3f col;             float x = ((float)w - 256);             float y = -((float)h - 256);             if (h == 256||w==256)col = vec3f(0, 0, 0);//axes             else col = vec3f(1,1,1);//background             if (y==x)col = vec3f(0, 0, 0);//straight line             if ((y*y) == (4*16*x))col=vec3f(1, 0, 0);//parabola             int r = int(255.99 * col.x);             int g = int(255.99 * col.y);             int b = int(255.99 * col.z);              ofs &lt;&lt; r &lt;&lt; " " &lt;&lt; g &lt;&lt; " " &lt;&lt; b &lt;&lt; "\n";         }     }     ofs.close(); }    This program plots only a few points which, upon checking the debugger, I found out to be : (0,0),(225,120),(196,112),(169,104),(144,96) and so on [these are the coordinates after origin is translated to (256,256), the center of the image]  I want to know why this is happening and how to fix this.  here's the output image plot.ppm :
Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
Is there a limit to the number of Power Armor sets you can keep? I've seen videos of some folks having several armor sets (4 is the most I've seen so far) standing about on their settlement. I'm wondering if having too many would cause some sets to disappear. They're not like guns/items that you can safely store in settlement crates, the suits kind of just... stand around. (I know there's the extra step of taking out the fusion cores, so that NPC's don't use them.)  Is there a limit to the number of Power Armor sets you can keep? Installing Steam on Debian I have ran into some issues when it went down to install Steam on Debian. The console as well as Apper comes up with missing dependencies  and the package isn't going to install. How can a file be copied? How to center an element horizontally and vertically Writing my first script so I'm sure this is a basic question, but can someone please explain to me why I can:  cd ~ cd bin cd ~/bin cd 'bin'   But not  cd '~' cd '~/bin'   I need to cd to a directory path with a space in one of the directory names, so I need the quotes (it's Windows Program Files under wine). I can get around it with two cd commands, but why can't I put ~ in quotes?  If I type cd '~' (or cd "~") I get:  bash: cd: ~: No such file or directory I am trying to find a way with QGIS to get the intersection area of more than 2 layers.  All the tools in QGIS take just the 2 input layers.  For example in the image below, I have 4 layers and I want to retrieve just the black area.   Furthermore, I need to retrieve the count attribute and add it to the intersected area attribute table (in this case 4)    I know there is a tool that does the trick in ArcGIS, but is there a QGIS solution? I use the listings package for code listings and I turned the line numbers on. But they appear left of the paragraph. I want them inside the paragraph. In the documentation it looks just right. Here is my code:  \documentclass[12pt,a4paper]{scrartcl} \usepackage{listings} \lstset{numbers=left} \begin{document} \section{Test} Test \begin{lstlisting}     test() \end{lstlisting} \end{document} How can I compute the distance between two coordinates in TikZ? Given two points (defined, for instance using nodes), I want to compute the distance between them.   Is there some build in functionality in tikz to do this? If not, how can it be done using the mathematical engine?   The application I have in mind is to draw an circular arc centered at (a) and passing through some second point (b), where only (a) and (b) are known. can I reflectively instantiate a generic type in java? Is it possible to reflectively instantiate a generic type in Java? Using the technique described  I get an error because class tokens cannot be generic. Take the example below. I want to instantiate some subclass of Creator that implements Creator. The actual class name is passed in as a command line argument. The idea is to be able to specify an implementation of Creator at runtime. Is there another way to accomplish what I'm trying to do here?  public interface Creator&lt;T&gt; {     T create(); } public class StringCreator implements Creator&lt;String&gt; {     public String create() { return new String(); } } public class FancyStringCreator implements Creator&lt;String&gt; {     public String create() { return new StringBuffer().toString(); } } public static void main(String[] args) throws Exception {     Class&lt;?&gt; someClass = Class.forName(args[0]);     /*ERROR*/Class&lt;? extends Creator&lt;String&gt;&gt; creatorClass = someClass.asSubclass(Creator.class);     Constructor&lt;? extends Creator&lt;String&gt;&gt; creatorCtor = creatorClass.getConstructor((Class&lt;?&gt;[]) null);     Creator&lt;String&gt; creator = creatorCtor.newInstance((Object[]) null); }   Edit: I like Marcus' approach as being the most simple and pragmatic without circumventing the whole generics thing. I can use it in my situation because I can specify that the class passed must be a subclass of StringCreator. But as Ericson pointed out the generic information is still there at the type level, just not at the runtime level so it is still possible to reflectively examine whether a given class implements the correct generic type. I'm going to guess that the answer is "no" based on the below error message (and ), but is there anyway to perform a cross-database query using PostgreSQL?  databaseA=# select * from databaseB.public.someTableName; ERROR:  cross-database references are not implemented:  "databaseB.public.someTableName"   I'm working with some data that is partitioned across two databases although data is really shared between the two (userid columns in one database come from the users table in the other database). I have no idea why these are two separate databases instead of schema, but c'est la vie... What's the difference between the server version and the desktop version? Does this polynomial evaluate to prime number whenever $x$ is a natural number? How to pick one number from each sorted list so that the difference between the minimum and maximum is as small as possible? How do I test a private function or a class that has private methods, fields or inner classes? How do I unit test (using xUnit) a class that has internal private methods, fields or nested classes? Or a function that is made private by having  (static in C/C++) or is in a private () namespace?  It seems bad to change the access modifier for a method or function just to be able to run a test. How can i integrate one SFDC org to another SFDC using Rest Api I am trying to integrate one Salesforce org to other org by using Oauth setup, I wanted to use  use consumer key and consumer secret key in my REST class to connect with the org, after connection part completion, I want to access Get(), Put(), Post(), etc. Including the ability to set Oauth and Authorization headers needed for Salesforce Rest API calls.  Actually I'm new in REST implementation so can you please explain me by using code samples. This is similar to , except it's a bug report, not a feature request.  Currently, the nominee's comments on his/her own post are not highlights, unless you click "add / show more comments"  When the page is loaded it looks like:    AfterI click "add / show more comments", it becomes:    Could we have the blue highlighting on the post owner's comments there all the time? It becomes difficult to see the nominees responses to questions, especially on nominations where there aren't enough comments to enable the "add / show more comments" features, like Matt's. ActiveResource timeout not functioning When I have these facts,   French coins were not found in the ruin. German coins were not found in the ruin.   which of these sentences are grammatically correct?  1.     No French and German coins were found in the ruin.   2.     No French or German coins were found in the ruin.   3.     No french nor German coins were found in the ruin.   I think 1 is correct but I'm not sure.  By the way, I can also say     Neither German nor French coins were found in the ruin.   Also, when you have an additional fact   Italian coins were not found in the ruin   which of these statements are grammatically correct?  1.     No French, German and Italian coins were found in the ruin.   2.     No French, German or Italian coins were found in the ruin.   3.     None of French, German and Italian coins were found in the ruin.   4.     None of French, German or Italian coins were found in the ruin.   Thanks, What is the standard error of the sample standard deviation? I read from  that the standard error of the sample variance is  $$SE_{s^2} = \sqrt{\frac{2 \sigma^4}{N-1}}$$  What is the standard error of the sample standard deviation?  I'd be tempted to guess and say that $SE_{s} = \sqrt{SE_{s^2}}$ but I am not sure. Determine all $f : \mathbb R \rightarrow \mathbb R$ such that $f(f(x) + y) = f(x^2 - y) + 4yf(x)$. Determine all $f : \mathbb R \rightarrow \mathbb R$ such that $$f\big(f(x) + y\big) = f(x^2 - y) + 4yf(x)$$ for all $x,y\in\mathbb{R}$.   $f(x) = 0$ is obvious , but how can we find all other functions?  Thanks in advance!