Decimals lost when converting Programming Software Development by Jennifer84 … so I beleive there is something that happens with the decimals when converting like I do. (Red Area) Is it possible… to not lose decimals when doing a conversion to string and back to double… Decimals dissapear during conversion Programming Software Development by Jennifer84 …;, Convert would have returned: 1 So it seems that the decimals is dissapearing in the conversion. What could I be doing… Re: Decimals dissapear during conversion Programming Software Development by mitrmkar [QUOTE]So it seems that the decimals is dissapearing in the conversion. [/QUOTE] atoi() converts a character … Re: Extracting decimals Programming Software Development by djidjadji …(decimals > int(decimals)): print 'decimal: ' + str(decimals), '%.20e' % decimals print 'int: ' + str(int(decimals)) if int(decimals)!=int(decimals+EPSILON): decimals += EPSILON break decimals *= 10 decimals = int(decimals) return decimals else… Extracting decimals Programming Software Development by dbmikus I am writing a function to extract decimals from a number. Ignore the exception and its syntax, I …; int(num)): decimals = num - int(num) while(decimals > int(decimals)): print 'decimal: ' + str(decimals) print 'int: ' + str(int(decimals)) decimals *= 10 decimals = int(decimals) return decimals else: raise… Loops provides an unexpected number of decimals? Programming Software Development by Bladtman242 … am I wrong? The following code outputs 16 decimals when the integer n is set to eg. 3…hours to execute, so I'm guessing quite a few decimals are in play :) [CODE=java] int n; …{ if (j > 0) { itn = itn - i; i = i / 10; decimals++; } if (j == 0) { j++; } while ((itn * itn) < n)… Re: Extracting decimals Programming Software Development by woooee …quot;, remainder if remainder > 0: decimals = num - whole ctr = 0 while (decimals > whole) and (ctr < …100): ctr += 1 decimals *= 10 whole, remainder = divmod(decimals, 1) print 'decimal: ' + str(decimals), print ' int: ' + str… Re: Loops provides an unexpected number of decimals? Programming Software Development by SasseMan … the answer and would just throw away the last 6 decimals. The important thing is that you know that, what… you have calculated, has 10 decimals of accuracy and the rest is error. You could also… instead of counting how many decimals you have progressed, just calculate the difference between the numerical… Re: Loops provides an unexpected number of decimals? Programming Software Development by SasseMan …get numerical errors and there will be 16 decimals because you are working with doubles and it…= 10; int j = 0; int decimals = 0; while ((itn * itn) != n && decimals < 10) { if (j &…gt; 0) { itn = itn - 1/i; i = i*10; decimals++; } if (j == 0) { j++; } while ((itn * itn) <… Re: Loops provides an unexpected number of decimals? Programming Software Development by Bladtman242 …am to understand that the number turns out with 16 decimals instead of 10, because, to the computer, 0,1…gt; 0) { itn = itn - 1/i; i = i * 10; decimals++; NumberFormat formatter = new DecimalFormat("###.###############"); String f = formatter.format… 0,0000000001 However there are still 16 decimals on itn. Re: Loops provides an unexpected number of decimals? Programming Software Development by SasseMan …;1371602]And with 1/i it will still calculate 16 decimals you say?[/QUOTE] As I said I'm not completely… myself about how the errors work, but the first 10 decimals should be correct and the last part is crap which… Help with making decimals show up always Programming Web Development by Jwallis … it will properly pass to the processing website. it adds decimals but they only show up in the total if there… is something other than .00. i need the decimals to show up in the total regardless of whether the… person entering values into the first 3 fields uses decimals or not. Here is the javascript: <script language="… Re: Loops provides an unexpected number of decimals? Programming Software Development by Bladtman242 … reading:) And with 1/i it will still calculate 16 decimals you say? Why is this? Re: Loops provides an unexpected number of decimals? Programming Software Development by SasseMan … huge number, or if you want more precision than 16 decimals. It all depends on what your doing, if there's… fixed number of decimals Programming Software Development by sgw … print all of them with [U]fixed number of decimals[/U], say two decimals, that is, the output will be: 12.30… Generating Pi decimals revisited Programming Software Development by TrustyTony Little clean up of vegaseat's code for generating pi decimals. Added number of decimals desired and string type return for easy use with ''.join() Re: fixed number of decimals Programming Software Development by jesseb07 … point cout.precision(2); // with 2 being the number of decimals using that, here's what happened in my test program… Re: C++ Builder Won't take Decimals Programming Software Development by apo I change everything to double : double i,j,... I don't get more zeros but it won't take the decimals like i/10 = 0.1 how can i get the decimals? Re: C++ Builder Won't take Decimals Programming Software Development by karolik [QUOTE=apo;1177786]I change everything to double : double i,j,... I don't get more zeros but it won't take the decimals like i/10 = 0.1 how can i get the decimals?[/QUOTE] Example? Not sure what you're saying. round off to 2 decimals places Programming Software Development by racerrunner … tell me how to convert a double variable to 2 decimals? I try using the below code but it cannot work… Easy question: Decimals to time Programming Software Development by japat …++ and would like to know the easiest way to turn decimals in to the form hours:minutes:seconds. You can assume… C++ Double - 8th point decimals Programming Software Development by ShawnMuller … elsewhere from the database and either have 0 or 2 decimals as in the example above. The code processes millions of… My 10 line calculator, I want it to display decimals when the equation calls for it. Programming Software Development by Chris9999 … gets annoying. I want it to automatically decide to show decimals. Displaying decimals in JavaScript?? Programming Web Development by jobojo I am new to JavaScript and have what may be a very simple and easy question to most. I am writing a simple block of code that I need to display dollar amounts with 2 decimals for change. For example instead of displaying the number 5, I need it to display 5.00. How can I do this? Any help will be greatly appreciated. SQL SUM Decimals Programming Databases by webwiredit … a table... the problem is that it is returning rouded decimals instead... like .5 always comes back as 1 ... Here is… String>Double Decimals not working Programming Software Development by NargalaX Hey, I'm making a math bot, and when you type in your equation it converts the numbers to doubles right away. Except, when doing any equation with a decimal, the decimal is ignored. Example 2 + 2 = 4 (No decimals, it works fine.) 2.2 + 2 = 24 (Decimal is ignored, 2.2 now equals 22.) How would I be able to fix this? Re: String>Double Decimals not working Programming Software Development by NargalaX … am assuming this will work with double values aswell as decimals? EDIT: I also got "The name 'NumberStyles' does not… C++ Builder Won't take Decimals Programming Software Development by apo … simple `[ j ]` are the int and the `[ i ]` are the decimals they must add up and multiply by the percent which… Re: C++ Builder Won't take Decimals Programming Software Development by apo i solved the problem, when ever i did a division like 1/10 it gave me a zero, in order to get 0.1 from the division above, i use instead 1*0.1 which is the same thing and it solved the problem with the decimal now the label is showing the decimals too for the interger thanks anyway... outputting large decimals Programming Software Development by mebob Hey, i was wondering if there was a way to output really large decimals, either to a file or to the output stream? because when i do this: [CODE] file << setiosflags(ios::showpoint) << setiosflags(ios::fixed) << setprecision(50); [/CODE] or do that with cout, the program crashes.