Category : modulo

to practice C++ i decided to write a modulo function. but it returns -nan(ind) how can i make it that the return is the rest of the division? #include <iostream> #include "Header.h" double modulo(double number1, double number2) { double intermediate_result_1=5; double result; int counter = 0; while (intermediate_result_1 < number1) { counter++; intermediate_result_1 = number2 ..

Read more

I want to implement 5%3=2 by avx. normal: int64 x = a % b math: int64 x = a-((double)a/b)*b avx: __m256 tmp1 = _mm256_cvtepi32_ps(data); I need convert a big number from int64 to float, then float overflow. how to solve overflow when convert int64 to float? Source: Windows Que..

Read more

This piece of educational code tries to return the count of dollars, quarters, dimes, nickels and pennies in a user entered integer value. When run, the program crashes and I can’t fix it. Most possibly it is a zero division that causes the crash. Any help is much appreciated. #include <iostream> using namespace std; int ..

Read more

This is my code: I have used try-catch to handle errors. Its showing timelimit exceeded. How can I optimize my solution. I have used nested loops. #include <bits/stdc++.h> using namespace std; int main() { try{ const long M = 1000000007; int T; long m,p; long long n,a,c,mm,pp,i=0,j=0; cin>>T; while(T>0){ cin>>n>>m>>p>>a>>c; long long exp=0; mm=m; long ..

Read more