determining if a value entered in loop is an odd or even number. Also, the value can't be int because it may be a decimal value(therefore i cant use the if(x%==0).
I need to replace the if(value%2 ==0) else num_even++ statement in my code with something else that will work with float to determine odd vs even.
#include <iostream> using namespace std; int main() { int num_values; float sum_values = 0; int num_neg_values = 0; int num_pos_values = 0;
N=1st number M=2nd number(accrding to my prof we will name it N and M ctr= increment of factorial of N, ctr2= increment of factorial of (N-M)
the problem is when i got the factorial of N / factorial of (N-M) i need to get the last non zero digit. so i use mod if it has zero in it. but mod can be only used with an int value. and when i change it to int value, the value of fact1 which is a float change
I am looking for a math/big num library, that allows me to convert 32/64/80 bot float numbers to string and vice versa.
Precision & accuracy is of importance here, and since this is an IEEE standard, i have high hopes that there are libraries for this out there, which would save me the hassle of trying to implement this myself...
I am working from my "ansi c" book by steven lawlor, page 73 program 2. write a program that accepts two numbers from the keyboard and prints the following information.
variables first second execution First number ? 7 Second number ? 2 the second goes into the first 3 times with a remainder of 1. the quotient is 3.5.
Code: #include <stdio.h> main() { int first, second; scanf(" %1i %1i", &first, &second); printf("First number ? %1i
[Code] ....
//I included this as I had some error message come up // before, not sure if this is correct though? } it shows what is expected but I cant get the 3.5.
I have tried %f and variations of width/precision but still not luck. Also, when I click on the application and put in the variables I press enter, the program executes and disappears so I cant see the result. how do I get the program to stay up until I want to get rid of it?
I just checking but confused with float. in that code same size int, and same type double are working but float showing nothing in printf..why?? i'm using GCC compiler int 32bit win7 os
I am entering numbers to float ... I want program to find out, which first number is not from specific interval. How to do it ? Example: Enter input : 5 10 20 30 50 46 . 30 is invalid. Here is the code :
Code:
while(scanf("%f",&input)!=EOF || input==0) { sum=input+sum; if (getchar() == '
why does the 2 variables, loanAmt and intRatem not work when they are multiplied together. The question is " Write a program that calculates the remaining balance on a loan after the first, second and third monthly payments. "
In w32 my program has been running ok, but when run in a w64, it crash at the printf. If I change the definition of the function to return double it runs ok. in printf format string - Wikipedia, the free encyclopedia , in the "type" section I see there is no definition to print a float, but %f is for double in fixed point.So the question is what is the correct way to printf a float? must I cast? or is it better to return double? if so, does it have a performance penalty?
Unless I'm missing something, it's now possible(ish)? A little concept is below, very rough around the edges. Still though, if this is valid by standard C++, why can't we have built-in support for float / double template parameters?
I have to convert my netpay which is a float to a string So if i have 356.26 it should output the sum of three hundred fifty-six and 26/100 dollars my program function works for the sum of three hundred but after that it spits out garbage.
Question: A computer uses 10 bits to store integers with 1 bit for a sign. It stores an approximation of real numbers in 10 bits. The first bit of the first five is the sign of the mantissa and the other four bits are the mantissa. The first bit of the second five is the sign of the exponent and the other four the exponent.
1)What is the range of integers?
2)what is the range of real numbers(Float Type)
The first question was simple. I just found the smallest 10 digit binary number 1000000000 = -512 and then found the largest 10 digit binary number which would have to be 0111111111 = 511, therefore the range of integers is from -512 to 511.
For the second question - I am either making this harder than it is, or it really is a challenging question. So I followed the steps and first I was thinking I would take the number 1000000000 and convert this to a decimal (assuming its a 10 bit float)...But, can you even do this with a 10 bit float??
I ended up getting 1000000000 (after denormalizing) = .000100000 = 0.625.. would that be the minimum range? If so, then I know what I need to do to find the maximum , but if not - then I am really lost.
My Process was:
1.00000 X 2^(-4) = my final result of 0.625 after converting.