• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

modulus on a float value?

cirthix

Diamond Member
is there a way to do this? google calculator can handle a float%float calculation, so can c?

if you have a better way to round to the nearest half than to do the following, please tell.

n -n%1 + round(n%1)

round is a function that just rounds to the nearest integer
 
How about ((float)((int)((2*n) + .5)) / 2) Or something to that effect

In English - multiply by 2, add .5, cast to int to chop off all decimals. Cast back to float and divide by 2.
 
Originally posted by: IHateMyJob2004
Originally posted by: cirthix
thank you mugs, you gave me the idea for this
int(n) + (round(n-int(n)))/2

My idea is better.


haha, you dont know what the hell you are talking about. thanks for trying to help though 🙂
 
Back
Top