473,320 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Can we use modulo to compare two floats?

1
can't we use modulo to compare two float
Nov 6 '12 #1
3 1763
donbock
2,426 Expert 2GB
The modulo-division operator (%) is only permitted if both operands are integral types. Floating point operands are not allowed.
Nov 6 '12 #2
Rabbit
12,516 Expert Mod 8TB
You can fake it by multiplying by 10 to the power of how many decimals you want. Convert to an integer. Do your mod.
Nov 6 '12 #3
whodgson
542 512MB
fmod()returns a double from two double arguments and is defined in cmath header
Nov 8 '12 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Griff | last post by:
Test program: =============================================================== t = 5.8 interval = 2.0 while t < 6.1: print "%s mod %s = %s " % (t, interval, t % interval ) t += 0.1...
3
by: Tjerk Wolterink | last post by:
I posted my problem earlier, but i simplified the examples, and i know what the cause of the problem is, but i dont know the solution, my xml file: <?xml version="1.0" encoding="ISO-8859-1"?>...
1
by: jt | last post by:
Looking up into Crypto.PublicKey.RSA, I see there is a computed value named "u" for which I can't see the use. The value of "u" is the inverse of p modulo q, in the code: obj.u =...
10
by: john blackburn | last post by:
Hi, I am trying to get an extremely simple character string encryption function to work using modulo 10 arithmetic. void ccencode(UNSIGNED8* pattern) { UNSIGNED8 key = CCKEY; UNSIGNED8...
2
by: Alexander | last post by:
I played a little bit with modulo cause I wanted to implement a small parser for functions as I stumbled over a calculation error. First I thought the reason might be a type conversion I did...
11
by: Ben Blank | last post by:
I have a loop which iterates over an array in a particular order: for (j = 0; j < 16; j++) T = ...; The loop proceeds normally for j = 0 through j = 4, but gives an IndexOutOfRangeException at...
12
by: Chadwick Boggs | last post by:
I need to perform modulo operations on extremely large numbers. The % operator is giving me number out of range errors and the mod(x, y) function simply seems to return the wrong results. Also,...
4
by: inkexit | last post by:
I'm writing a basic piece of software that will tell me how many shares of stock I can buy if the shares cost X each and I have Y to spend. I have it coded as: int main() { float price,...
5
by: shumaker | last post by:
The VS help files list % as the modulo operator, but I read in another post that someone said it was the remainder operator. I'm getting -2 % 64 = -2, but I need 62 or -62, because I am trying...
3
by: Michel Walsh | last post by:
Mathematically, r = a modulo b (b being the divisor) is defined such that if b <0, and if r <>0, its sign should be the sign of b. C# does not follow this definition. int indx = -1;...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.