Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C
Can we use modulo to compare two floats?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
naan
New Member
Join Date:
Nov 2012
Posts:
1
#1
Can we use modulo to compare two floats?
Nov 6 '12, 04:06 PM
can't we use modulo to compare two float
donbock
Recognized Expert
Top Contributor
Join Date:
Mar 2008
Posts:
2427
#2
Nov 6 '12, 04:34 PM
The modulo-division operator (%) is only permitted if both operands are integral types. Floating point operands are not allowed.
Comment
Post
Cancel
Rabbit
Recognized Expert
MVP
Join Date:
Jan 2007
Posts:
12517
#3
Nov 6 '12, 04:43 PM
You can fake it by multiplying by 10 to the power of how many decimals you want. Convert to an integer. Do your mod.
Comment
Post
Cancel
whodgson
Contributor
Join Date:
Jan 2007
Posts:
542
#4
Nov 8 '12, 04:08 AM
fmod()returns a double from two double arguments and is defined in cmath header
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment