scanf function doesn't read doubles correctly In my homework, I have some problems with scanf function:  /* Can Doğu */ #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;math.h&gt;  /* My Function prototypes */ double calculate_profile_area(int edgecount,double edgelength); // Has two parameters: edgecount &amp; edgelength. Returns double type value. double calculate_volume(double a,double h); // Has two parameters: profilearea &amp; boxheight. Returns double type value. double calculate_price(double p); // Has one parameter: volume. Returns double type value.  /* My main function */ int main(void) {  /* Variables &amp; input-output part */ int count; double length,height,area,volume,price; area=0.0,volume=0.0,price=0.0; printf("Enter edge count for box profile: "); scanf("%d",&amp;count); printf("Enter the profile-edge length and box-height: "); scanf("%lf%lf",&amp;length,&amp;height);  /* Calling my functions */ area=calculate_profile_area(count,length); volume=calculate_volume(area,height); price=calculate_price(volume);  /* Printing the results */ printf("Box profile area is %.2lf cm square.\n",area); printf("Box volume is %.2lf cm cube.\n",volume); printf("Total sugar price is %.2lf TL.\n",price); system("pause"); return(0); }  /* calculate_profile_area function */ double calculate_profile_area(int edgecount,double edgelength) { double profilearea=0.0; profilearea=edgecount*((edgelength*edgelength)/(4*tan(M_PI/edgecount))); return(profilearea); }  /* calculate_volume function */ double calculate_volume(double a,double h) { double v=0.0; v=a*h; return(v); }  /* calculate_price function */ double calculate_price(double p) { double cost=0.0; if(p&gt;=0 &amp;&amp; p&lt;=500)     cost=p*120; else if(p&gt;=501 &amp;&amp; p&lt;=1000)     cost=p*100; else if(p&gt;=1001 &amp;&amp; p&lt;=2500)     cost=p*80; else if(p&gt;=2501 &amp;&amp; p&lt;=5000)     cost=p*65; else if(p&gt;=5001)     cost=p*50; return(cost); }   When I enter a double value (2.15), my compiler reads it as 2.14999999. Thus my 'area' result is calculated as 54.59 (which should be 54.60). Any idea why my result is not correct?
Is floating point math broken? Consider the following code:   0.1 + 0.2 == 0.3  -&gt;  false   0.1 + 0.2         -&gt;  0.30000000000000004   Why do these inaccuracies happen?
On the paragraph explaining arithmetic expansion,  uncovers 2 different ways of evaluating an expression, the first one uses $(( EXPRESSION )) and the second one uses $[ EXPRESSION ]. The two ways seem pretty similar as the only difference I have found is:     $[ EXPRESSION ] will only calculate the result of EXPRESSION, and do no tests:   Yet, I am intrigued because the same document recommends using $[ EXPRESSION ] rather than $(( EXPRESSION )).     Wherever possible, Bash users should try to use the syntax with square brackets:   Why would you want that if less tests are being done? Calculate the limit of two interrelated sequences? What is the difference between a tatkal and premium tatkal ticket in Indian Railways? Which style is preferred? Is there a good reason for one vs. the other?  Thanks in advance!  1) cmds.each do |cmd|    end  2) cmds.each { |cmd|    }   Example code:  cmds = [ "create", "update", "list", "help" ]  # Block style one # cmds.each do |cmd|   puts "loop1, cmd: #{cmd}" end  # Block style two # cmds.each { |cmd|   puts "loop2, cmd: #{cmd}" } Here $p$ and $q$ are co-prime integers. Is it necessarily an algebraic number? How to overcome Acrobat Reader error 131 with a pdfLaTeX doc? I'm generating a PDF document with pdflatex (more precisely, latexmk invoked from TexMaker 3.4. My LaTeX install is TeXLive 20120719). I can read the document fine in Okular and Gmail's attachment preview, but a colleague that runs Acrobat Reader on Windows reports: "There was a problem reading this document (131)".  EDIT: The error disappears when using \usepackage[demo]{graphicx}, which puts black boxes instead of the real images. They are all PDFs, PNGs and JPGs. Instead of using demo, I added the code for a \demoincludegraphics command, which makes the file work in Reader when using it to replace the logo in the headers, as shown below. But enabling it (using \includegraphics instead of \demoincludegraphics) and removing everything else also works in Reader! There is some strange global interaction that makes the file appear broken to Reader when enabling all the graphics...  My code compiles fine, reason why I only attach the preamble and a simple text for a Minimal Working Example:  \documentclass[12pt,lettersize,twoside]{article}  \usepackage[utf8]{inputenc} \usepackage[spanish,es-tabla]{babel}   \usepackage[fixlanguage]{babelbib} \usepackage{amssymb,amsmath} \usepackage{graphicx}    \usepackage{array}    \usepackage{caption} \usepackage{subfig} \usepackage{rotating} \usepackage{booktabs} \usepackage{multirow} \usepackage{calc} \usepackage{stfloats} \usepackage{fixltx2e} \usepackage{url} \usepackage[colorlinks=true,linkcolor=blue,citecolor=red]{hyperref} \usepackage[all]{hypcap}  % Margins \usepackage[top=2cm, bottom=2cm, left=3cm, right=2cm]{geometry}  % Make header show up in the first page \makeatletter \renewcommand\maketitle{\par \begingroup     \renewcommand\thefootnote{\@fnsymbol\c@footnote}%     \def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}%     \long\def\@makefntext##1{\parindent 1em\noindent             \hb@xt@1.8em{%                 \hss\@textsuperscript{\normalfont\@thefnmark}}##1}%     \if@twocolumn     \ifnum \col@number=\@ne         \@maketitle     \else         \twocolumn[\@maketitle]%     \fi     \else     \newpage     \global\@topnum\z@   % Prevents figures from going at top of page.     \@maketitle     \fi     \thispagestyle{fancy}\@thanks % was {empty} \endgroup \setcounter{footnote}{0}% \global\let\thanks\relax \global\let\maketitle\relax \global\let\@maketitle\relax \global\let\@thanks\@empty \global\let\@author\@empty \global\let\@date\@empty \global\let\@title\@empty \global\let\title\relax \global\let\author\relax \global\let\date\relax \global\let\and\relax } \makeatother  % Remove date field in title; Remove preceding vertical space \makeatletter \renewcommand{\@maketitle}{ \vspace{-3cm} \begin{center}% {\LARGE \@title}\\ \vspace{2mm}% {\@author} \end{center}% \par} \makeatother \makeatletter  % Demo includegraphic boxes \newcommand{\demoincludegraphics}[2][]{%   \setlength{\fboxsep}{-\fboxrule}% Remove frame separator/gap   \framebox{\rule{0pt}{100pt}\rule{150pt}{0pt}}% Framed box of 150pt x 100pt }  % Headers Config  \usepackage{fancyhdr} \pagestyle{fancy} \fancyhead{} \renewcommand{\headrulewidth}{0.4pt} \setlength{\headheight}{2.2cm}  \addtolength{\textheight}{-1.62cm} \fancyhead[LO,RE]{\demoincludegraphics[height=1.6cm]{logo-slogan}} \fancyhead[LE,RO]{}  % Footers Config \fancyfoot{} \renewcommand{\footrulewidth}{0pt} \fancyfoot[C]{\thepage}  % Notas al pie etiquetadas por simbolos   \renewcommand{\thefootnote}{\fnsymbol{footnote}}  \title{Doc Title} \author{My name}  \begin{document}  \maketitle  This is a test. It includes graphics and other floats.   \end{document}   EDIT: I found a workaround: Processing the generated pdf file through Ghostscript, as follows:   gs -dSAFER -dBATCH -dNOPAUSE  -sDEVICE=pdfwrite -sOutputFile=output.pdf input.pdf   where input.pdf is the file generated by pdfLaTeX, and output.pdf the one that will be readable by Adobe Reader and the rest of the PDF readers. What are valid values for "data defined" labeling settings? Why doesn't the definition of a category require an explicit notion of morphisms equality? I am learning basics of the category theory (CT).  I do understand that CT is a modern powerful framework to describe various branches of mathematics in a unified way.  I do admit that category's definition tells a lot about the whole thing and focuses on the most important properties, shadowing unnecessary details. However, the more I go forward, the more it feels like it should explicitly require a notion of morphisms equality (like it does with morphism composition). It feels so because equality or inequality of morphisms arises everywhere, since the very beginning: any commutative diagram eventually reduces to an equality of two different paths and many other things involve equality as well. Even composition is defined grounding upon an (implicit) equality!  I'll try to give an example of my concern. Consider $\mathbb{SET}$. Its objects are sets and morphisms are functions. Now, let's recall that functions are sets as well - to be more precise, a function $f : A \mapsto B$ is a subset of a $A \times B$ obeying certain properties, which I omit. Thus, one could argue that $f$ is both a morphism between objects $A, B \in Obj(\mathbb{SET})$ and an object defined as a set of pairs $\{ (a_1 \in A, b_1 \in B), ..., (a_n \in A, b_n \in B) \}$ and those are equal because both are essentially exactly the same thing.  I hope my concern is clear and I need some kind of "conceptual insight" from knowledgeable people to move forward. Please give me the right perspective. Windows 7's PATH and environment variables are corrupted List all commands that a shell knows What can I type at my shell (which happens to be bash) that will list all the commands that are recognized?  Also, does this differ by shell? Or do all shells just have a "directory" of commands they recognize?  Secondly, different question, but how can I override any of those? In other words how can I write my own view command to replace the one existing on my Ubuntu system, which appears to just load vim. Google Chrome automatically adding websites to my list of search engines? I have noticed that certain websites (e.g. Stack Exchange sites, Dell, etc.) are automatically added to my list of search engines in Google Chrome.   They even add a keyboard shortcut to their entry. Here are some examples:   Dell: Keyboard -> Dell.com Stack Exchange Web masters: Keyboard -> webmasters.stackexchange.com Reuters: Keyboard -> reuters.com   Q1: Is this the default behavior in Chrome? (to let websites add themselves to the list of search engines?)  Q2: Is it possible to disable this behavior in Chrome?   Note: I'm running the latest version of Chrome: 11.0.696.57 on Windows 7 64, and I only have one extension installed: Google URL shortener. I have some shares that are mounted during login. I used Users &amp; Groups' "Login Items" panel to do this. When I login, all of the shares pop up in their own Finder windows.  How can I keep the Finder windows from popping up at login? I've already tried checking the Hide checkbox. Mathematica not plotting whole logarithmic function Is it possible to use multiple desktop environments on same system? What are the most suitable filter holders for my Samyang 14mm autofocus prime lens? I've looked into the ones from Haida and Nisi which are both suitable, though they're quite pricey for me currently - does anybody know of any cheaper possible alternatives? I understand there's the 160mm specifically made for use with this lens, though obtaining filters for it is difficult and limited. I'm hoping for something which may be cheaper than both Haida and Nisi, and still suitable for the 14mm lens. Thanks! Why rationalize the denominator? In grade school we learn to rationalize denominators of fractions when possible. We are taught that $\frac{\sqrt{2}}{2}$ is simpler than $\frac{1}{\sqrt{2}}$.  says that "there is a bias against roots in the denominator of a fraction". But such fractions are well-defined and I'm failing to see anything wrong with $\frac{1}{\sqrt{2}}$ - in fact, IMO it is simpler than $\frac{\sqrt{2}}{2}$ because 1 is simpler than 2 (or similarly, because the former can trivially be rewritten without a fraction).  So why does this bias against roots in the denominator exist and what is its justification? The only reason I can think of is that the bias is a relic of a time before the reals were understood well enough for mathematicians to be comfortable dividing by irrationals, but I have been unable to find a source to corroborate or contradict this guess. What is the name of the character $\wp$? What is the name of the character whose code is $\wp$ ?  Thanks Can a homomorphic encryption scheme be made CCA2 Secure? Is it possible to modify a homomorphic encryption scheme so that it can be CCA2 secure?  From the definition of a homomorphic scheme, it seems that it is malleable, which would result in lack of CCA2 security. So, if we use the regular method to convert a CPA secure scheme to CCA2 secure scheme (using a hash of the message and a random value), will it still preserve its homomorphic property? Please correct me if my understanding is wrong. Apex REST API - Unable to set StatusCode to 429 I am trying to set the status code to 429 for Too many request using the code below:  if(Limits.getQueries() &lt; Limits.getLimitQueries()){               upsert UpdateData;               }               else if((Limits.getQueries() &gt;= Limits.getLimitQueries()))               {                   RestContext.response.statusCode = 429;                   UpdateError[] err = new UpdateError[]{                    new UpdateReturnError(UpdateData.Id, 'Too many Requests', 'Error updating MessageID ' + msg.MessageId)                 };                 RestContext.response.responseBody = Blob.valueOf(JSON.serialize(err));                 RestContext.response.addHeader('Content-Type', 'application/json');                 break;               }             }   I am getting the following error in the raw response:    Can someone help me out with this? I shifted to Ubuntu 10.10 now I am facing problem to have C/C++ compiler. What are the possible ways so that I can use C/C++ compiler using all the libraries (like graphic, math, conio, stdlib, etc) as in Microsoft Windows creating executable file?