ИНФОРМАЦИОННЫЕ И КОММУНИКАТИВНЫЕ
ТЕХНОЛОГИИ
UDK 004
Xolmirzayev I.
Uzbekistan, Namangan Xashimov А.
Akbarov N.
Uzbekistan, Fergana USING LONG ARITHMETIC IN C++ PROGRAMMING LANGUAGE
Annotation: In this article there is given a way how to solve problems which is working with huge numbers in many programming languages. In Solving these problems we use "Long arithmetic "method in C+ + programming language. Using this method can help to solving mathematic and managment problems and create a new programs , working with mikrocontrollers, also provide for working programs truely.
Key words: program, elementary function, long arithmetic, fulfill subtraction, multiplication, division, cryptography, vector-type, mathematical and financial questions, sports programming.
Nowadays, demands for computer programs are increasing day by day. In the meantime, we face up to several problems while creating new programs and try to find the ways of solving them on time. One of these problems is working with huge numbers. In order to find solution for these problems, we are using C++ programming language. There are various types that work with numbers in this programming language. These types are demonstrated in the following table. (Table-1)_
Type Volume, bayt Border
unsigned short int 2 0 - 65535
short int 2 -32768 - 32767
unsigned long int 4 0 - 4294967295
long int 4 -2147483648 - 2147483647
int (16 razryad) 2 -32768 - 32767
int (32 razryad) 4 -2147483648 - 2147483647
unsigned int (16 razryad) 2 0 - 65535
unsigned int (32 razryad) 4 0 - 4294967295
Float 4 1,2e-38 - 3,4e+38
Double 8 2,2e-308 - 1,8e+308
Table-1. Types that work with numbers
If we focus on all types above, they have their own limits. It means that in calculations, we cant reach higher results because of these limits and there may appear some errors in accounts. In science, the way of solving these problems is called "long arithmetic". In long arithmetic, not operating numbers but lines and vectors are used. We can say, this way is an adapted version of addition, subtraction,
Экономика и социум" №5(48) 2018
www.iupr.ru
1615
multiplication, division to the programming language.
In long arithmetic, we can fulfill subtraction, multiplication, division and other elementary functions with the help of processing machines. However, long arithmetic is widely used in the following areas:
2. Working with microcontrollers
3. In cryptography
4. Mathematical and financial questions
5. Sports programming (Olympics)
During the process of creating the program, number of problems arise in using and reading very large values. For example, if we consider the rate of the number value of 10, 500 numbers, it can't be calculated by the number of standard variables in the program. Long arithmetic is used under similar conditions. We will analyze the program code that is done on this method.
9. First, we need to download to the program a list of necessary libraries.
♦include <cstdlib> ♦include <iostream> ♦include <vector> ♦include <stdio.h>
We will download extra vector library and stdio library to C ++ programming language standard library. The reason we keep all information in vector. In common language, vector can be described as "smart array". That is, the vector also keeps the same type values as an array. The main advantage is recognized as a change in the number of vector elements dynamic.
10. Set up to use standard Namespace.
using namespace std;
11. "large_number" elements "int" which is relevant to the type of vector and the "base", "int" type variable declaration.
typedef vector <int> large_number;
int base=1000*1000*1000;
4. The above declared that returns values in a vector type, adding function with two parameters that is relevant to this type.
Экономнка h соцнумм №5(48) 2018
www.iupr.ru
1616
large_number add(large_number x, large_number y)
{
int carry=0;
for(size_t i=0; i<max(x.size(), y.size())11 carry; ++i) {
if (i==x.size()) x.push_back(0);
x[i]+=carry+(i<y.size() ? y[i]:0); carry=x[i]>=base; if(carry) x[i]-=base;
}
return x;
J_
We add x and y variables with the help of this function, x variable will be used and returned as x result.
5.This function also sends back values in the above stated vector type and receives styrene and vector-type parameters, and called "read".
large_number read(string s, large_number x)
{
for(int i=(int)S.length(); i>0; i-=9) if (i<9)
x.push_back(atoi(s.substr(0,i).c_str())); else
x.push_back(atoi(s.substr(i-S,S).c_str())); return x;
J_
This function adds to the end of the vector string-type s variable value to the vector type x variable value step by step converting 9 characters into x number with the help of "atoi" function. In this case, the number of type line is placed in reverse order to the vector.
6. Printing the parameters of vector type and returning no values function.
Экономнка h соцнумм №5(48) 2018
www.iupr.ru
1617
void print(large_number x)
{
printf ("%d", x.empty() ? 0: x.backO);
for (int i=(int)X.size()-2; i>=0; —i) printf ("%09d", x[i]);
}
We use this function when printing vector values. If you pay attention, the information in the vector is being printed in reverse order. Because the reverse was the case in vector line too. In order to have correct answer reverse order is required here as well.
7. The main part of the program.
int main(int argc, char *argv[]) {
large_number x,y,z;
string number_l, number_2;
cout«" First number= " ; cin»number_l ; cout«" Second number= "; cin»number_2; x=read(number_l, x); y=read(number_2, y); z=add(x,y); cout«" The result= print(z); cout«endl ; system("PAUSE");
return EXIT_SUCCESS;
}
Here is added and the collection of vector-type x, y, z, typical of the screen to read the data string number_1, number_2 variables are declared number_1 and number_2 them learn to read, number_1 and number_2 "read" function, x and y variables, "add" setting x variable value of the sum z mastered the "print" function in the z recognize the value.
By running the application code, as x proof we try to add the larger numbers than above stated types limit with the help of this program.
First number= 3005198612051988160120162017 Second number= 1902196403121965300508082702 The result= 4907395015173953460628244719 Для продолжения нажмите любую клавишу . . .
And we can see the program is working properly. We will be able to work with huge numbers in this program.
Экономика и социум" №5(48) 2018
www.iupr.ru
1618
It can be concluded that we can work with the huge numbers using the long arithmetic program. Using long arithmetic program in solving complex questions and creating various programs ensures correct operation of the program.
Literatures:
- E.Horowitz, S.Sahni, S.Anderson-Freed, "Fundamentals of data structures in C", Second edition, University Press(India), New Delhi, 2008 y.
- http://e-maxx.ru/algo/big_integer.
Баканова Е.И. студент 2 курса энергетический факультет Ульяновский государственный технический университет Россия, Ульяновская область, г. Ульяновск
ВИРТУАЛЬНАЯ РЕАЛЬНОСТЬ КАК ЧАСТЬ РЕАЛЬНОСТИ
Аннотация: Статья посвящена рассмотрению понятия виртуальной реальности в гуманитарном аспекте, предполагающем изучение виртуальности в философии, психологии и других сферах. Объясняется понятие термина «виртуальная реальность», анализируются его качества и принадлежность этих качеств к другим реальностям.
Ключевые слова: виртуальная реальность, виртуальность, виртуалистика, философия.
Bakanova E.I.
second year student of Power Engineering faculty of Ulyanovsk state technical university, Ulyanovsk city, Ulyanovsk region, Russia VIRTUAL REALITY AS PART OF REALITY.
Abstract: Article is devoted to consideration of a concept of virtual reality of the humanitarian aspect assuming studying of virtuality in philosophy, psychology and other spheres. The concept of the term "virtual reality" speaks, his qualities and belonging of these qualities to other realities are analyzed.
Keywords: virtual reality, virtuality, virtualistika, philosophy.
Введение.
Сегодня, в условиях продвижения современных технологий, появляется интерес к явлению виртуальной реальности и его взаимодействию с реальностью социальной. Собственно поэтому изучение этого феномена является одним из течений в современной философии. При возросшем внимании к данному вопросу, не удивительно, что понятие «виртуальная реальность», возникшее в области компьютерных технологий, стало употребляться во многих сферах науки и культуры, в научных работах и в быту. Отсюда и появилась неопределенность, порой противоречивость его объяснения и нужда философского осмысления, изучения ее онтологического статуса, антропологических и социокультурных оснований, что позволит по-новому взглянуть на современное общество. Внедрение современных
Экономика и социум" №5(48) 2018
www.iupr.ru
1619