The following piece of code outputs 0.1000000000001 float a=0.1; printf("%lf",a); But if I add a 10 times as long float b=0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1+0.1; printf("lf",b); It outputs as 0.999999999999989 But if a=0.1 is stored as 0.1000000000001 then the answer should be greater than 10 due to the 1 in last column.Then why is the output less then 10

Member Avatar
Member Avatar
+0 forum 3

I wrote a short program to factor numbers, and it works in most cases. The problem I am getting is that when I use a very large number I get "Floating point exception: 8." I am assuming that I am trying to divide by 0 on line 43 or 46, but I cannot quite figure out when/why it would do this. primes.txt is a file with the prime numbers between 2-1,000,000 with one number to a line. primes.txt: https://www.dropbox.com/sh/e3u6prd0pqrhet0/4M4yXYyJIF/primes.txt // // main.cpp // Factor // // Created by Samuel Witt on 11/8/12. // Copyright (c) 2012 Samuel Witt. All rights …

Member Avatar
Member Avatar
+0 forum 4

#include<stdio.h> #include<conio.h> void main() { float a[5][5],x[3];float t,s; int i,j,k; printf("enter a matrix of order 3*4"); for(i=0;i<3;i++) { for(j=0;j<4;j++) { scanf("%f",&a[i][j]); } } for(i=0;i<3;i++) { for(j=0;j<4;j++) printf("%f ",a[i][j]); printf("\n"); } for(i=0;i<=1;i++) { for(j=i+1;j<=2;j++) { t=a[j][i]/a[i][i]; for(k=i;k<=3;k++) a[j][k]=a[j][k]-t*a[i][k]; } } printf("The upper triangular matrix is as\n"); for(i=0;i<3;i++) { for(j=0;j<4;j++) printf(" %f",a[i][j]); printf("\n"); } for(i=2;i>=0;i--) { s=0.0; for(j=i+1;j<3;j++) { s=s+a[i][j]*x[j]; x[i]=(a[i][3]-s)/a[i][i]; } } printf("\nRoots of the equation are"); for(i=0;i<=2;i++) printf(" %f",x[i]); getch(); }

Member Avatar
Member Avatar
+0 forum 7

I am doing following code to get the output upto 5 decimal characters of any number inputted by user when divided by 1, I have to use typecast it with (float) , can any one tell me how this can be done without typecasting or using float constant.. int main() { int n; scanf("%d",&n); printf("%.5 ", 1/(float)n); return 0; }

Member Avatar
Member Avatar
+1 forum 2

Hello dear DaniWeb members I have a problem with the new site I´m making nad I was wondering if anyone could help me. Well its because I have big content box where I´m keeping 2 news boxes in and a right box but when I put the boxes to have float left then the big content box which has a background color then it won´t follow the site all the way down it just stops showing but when I remove the float left then the big box follows as long as there is text? Please help me :( Here is …

Member Avatar
Member Avatar
+0 forum 4

Hi there, during developing website for my father's company ( [website](http://www.pgum-sill.pl/nowa_strona/index.html) ) I find out that I have problem with personalization of different lists. In this case I wanted to make a floating menu like thise one here: [Floating Menu](https://d2o0t5hpnwv4c1.cloudfront.net/018_Floating_Menu/demo/dhtml_float_menu_final_nettut.html) (this page is from this [Tutorial](http://net.tutsplus.com/tutorials/html-css-techniques/creating-a-floating-html-menu-using-jquery-and-css/)) At the pages above foating menu looks fine. I have copied all the "floating menu code" to my father's website and have a problem. I can say that nothing is ok. I don't know why CSS is not working correctly. Why the menu is not recognizing CSS attributes?

Member Avatar
Member Avatar
+0 forum 9

Hi! I have a decimal number (e.g 6433) and would like to see the process of converting this to IEEE short real floating point format! Any help is appreciated ;)

Member Avatar
Member Avatar
+0 forum 1

I started writing this code as practice for my Computer Science class. The goal was to help with structs and arrays. But I have come to a problem. The file will compile, but returns a message saying "floating point exception." Doing research I see there could a few reasons, but I can't stop any problems with my code. I was hoping if I had someone more experienced look at the code, maybe I can get help understanding what I did. BEWARE: I am just a beginner with C++. This may or may not hurt your eyes. Just some info on …

Member Avatar
Member Avatar
+0 forum 1

working on a 32bit architecture and i'm adding two arrays together slot by slot into a third array so if I have 3,4,4 and 4,4,4 in the arrays the third array should contain 7,8,8 at the end of the function I was able to pass in the arrays correctly and the amount of items into the function arleady, i know this because I ran test code now i'm working on the addition part of it, here is what I have, the logic makes sense to me but it's still seg faulting...ideas? [CODE];*************************************ADD ARRAY********************************************** segment .bss ; segment .data summessage db …

Member Avatar
+0 forum 0

The End.