How to I leave out the whole number in a number and only use the decimal?
I will use 52546.1351351 as a example instead of 52546.1351351, I want 0.1351351
I know how display all of this... using the function setprecision()
Take its modulus when divided by one. mysteryfloat -= (mysteryfloat % 1) That will divide out the entire whole section and leave only the decimal remainder.
Thank you, you have been a big help lately also
so if i had a previous variable i was using
i would write the line like this
nextvar = prevar -= (prevar % 1)
Or you can go for helios's recommendation of modf, which is modulus for floats. Check his link for its usage. I personally don't think the code overhead is worth the worry in most cases but hey, who knows?
WAIT - you should not have that mod = part. That shold not really be done. You are cramming too many statements together and the flow is difficult to read. In addition you missed your semicolon.
Do your assignment on another line. Even if it doesn't lead to a syntax error it looks better and is much clearer.
tummychow: That's at least as bad, if not worse. Modulo can't be performed on floating point values (there's a math function that does that), so its operands have to be converted to integers. If the compiler is not automatically converting 1.0 to 1, then it's worse.
WAIT - you should not have that mod = part. That shold not really be done. You are cramming too many statements together and the flow is difficult to read. In addition you missed your semicolon.
okay but all those letters are variables that need to be used or i would be doing this on one line and to me i can read it perfectly...
so is line 10 how i do it?
Floats and doubles are practically interchangeable. Double is just *longer* than float.
Read the link that helios gave you. We don't give people links so they can read the address. It's so they can read what's on the other end of the link.
can turn into making a whole number with a decimal just a decimal....
im a semi intelligent guy that doesnt understand crap about math (pardon my language)
im making a semi intelligent guess and saying i wont need printf and all i may double param, fractpart, intpart; and fractpart = modf (param , &intpart);
and need to make param a variable?????
This seems really coplicated
i dont know ill look at that link a little more then google it then ask for more help