I was using GMP library for build an binary arithmetic, but for multiplication, I want to return a result a multiplication without carry..
How can I implementing it?
nb: the code below give a result of multiplication with carry -
void multi(){
-
int m_bit;int m_bit2;
-
char *op1;
-
char *op2;
-
char *final;
-
-
mpz_t hasil_acak,hasil_acak2,hasil_pangkat,hasil_exor_temp,hasil_multi,hasil_multi_temp,hasil_exor_temp0;
-
-
mpz_init(hasil_pangkat);
-
mpz_init(hasil_acak);
-
mpz_init(hasil_acak2);
-
mpz_init(hasil_exor_temp0);
-
mpz_init(hasil_exor_temp);
-
mpz_init(hasil_multi_temp);
-
-
mpz_init(hasil_multi);
-
-
printf("input m-bit pertama: "); scanf("%d",&m_bit);
-
gmp_randstate_t rand_state;
-
gmp_randinit_default(rand_state);
-
gmp_randseed_ui (rand_state, time(NULL));
-
mpz_rrandomb(hasil_acak, rand_state, m_bit);
-
//mpz_get_ui(hasil_acak);
-
op1 = mpz_get_str(NULL, 2, hasil_acak);
-
printf("[%s]\n", op1);
-
-
printf("input m-bit kedua: "); scanf("%d",&m_bit2);
-
gmp_randstate_t rand_state2;
-
gmp_randinit_default(rand_state2);
-
gmp_randseed_ui (rand_state2, time(NULL));
-
mpz_rrandomb(hasil_acak2, rand_state2, m_bit2);
-
op2 = mpz_get_str(NULL, 2, hasil_acak2);
-
printf("[%s]\n", op2);
-
-
mpz_addmul(hasil_multi, hasil_acak, hasil_acak2);//can I use other function or any code for replace this multiplication with carry? (I want a result of mutiplication without carry)
-
mpz_get_ui(hasil_multi);
-
final = mpz_get_str(NULL, 2, hasil_multi);
-
puts ("\n\nHasil MULTI:");
-
printf("[%s]\n", op1);printf("[%s]\n", op2);
-
puts("_*_");
-
printf("[%s]\n", final);
-
-
}
-
0 1723 Sign in to post your reply or Sign up for a free account.
Similar topics |
by: slashman |
last post by:
Hi,
I wud like to know how to create and use .lib files from a few c++
classes i have created that are common to a lot of my projects. My
guess is .lib files can b used in windows and linux (please correct me
if i'm worng). And if u guys cud also let me know where i cud find out
such information in the future (books or websites) it would b
x-tremely helpful
thanks in advance
vivek
|
by: Marco Segurini |
last post by:
Hi,
Actually the build of my solution gives as result an EXE and some DLLs.
Now, I am creating a new configuration that tranform the DLLs into LIBs.
The following semplified code explains one of the problems that arise
using a solution with a console project that creates the EXE and a lib
project that creates the LIB.
//------------------------------------------------------------------------
|
by: Leszek Gruszka |
last post by:
I have dhcpsapi.lib and dhcpsapi.h files.
I know, that *.h is for c++/c#.
Is there any method to use it in vb .net?
|
by: Sameh Ahmed |
last post by:
Hello there
Is there a way to use lib files as com objects?
I have an SDK of an API used to communicate with an EMC storage box that
contains only LIB, DLL, and C files.
Is there way to use these files in Vb.net?
Thanks in advance.
Regards
|
by: radishcarrot |
last post by:
Hi, I try to access the QuickTime COM/ActiveX DLL file, QTOControl.dll
in my VC++ codes as follows:
HINSTANCE OTOControlLib = LoadLibrary("QTOControl.dll");
But how do I access the methods in the dll file?? The problem lies in
that QuickTime did not provide the .h or .lib file for the DLL file??
Any solution??
Thanks alot
| |
by: Hugh |
last post by:
I would like to perform an addition without carrying of two integers...
I've got no idea how to do this in python, although I've been using it
for web/cgi/db work for a few years now.
Any help would be great.
Hugh
|
by: outofstep |
last post by:
Hit me up on AIM/YIM (oipaloi). I'm not a code monkey and would like to get some advice. Or hit up this thread right here.
I'm using DEV C++ as my compiler.
I'm trying to calculate SIN/COS/TAN, etc without the use of CMATH. Using two recursive functions for the power and factorial. Gotta do some other things as well, but right now I'm just wondering why my values are off. Just wondering where I'm going wrong. Here's the code I've got...
|
by: sunmat |
last post by:
To find number of character without space using java
Example:
String = prabu sun
No. of char =8
plz send me code
|
by: siluomm |
last post by:
hi.....i am btech2nd year student.please send me the programming of multiplication of two array using operator overloading concept in c++
|
by: JDOMPer |
last post by:
Don’t misunderstand me – I use AJAX, but I think there is a far simpler, elegant alternative that just uses Javascript, the DOM and Php ( hence - JDOMP) for data transfers, and is cross-browser without the need for work arounds. JDOMP works in recent versions of Explorer, Mozilla, Safari and Opera. Please note I will not deal with security issues which are always an issue whenever there is access to a database.
You can simply change text on...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |