Calculating large numbers in C++ without external libraries [closed] - c++

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I need to write a program that will perform operations on float numbers higher than 10^100.
I can't use any arbitrary precision mathematics libraries that are not included in GCC package by default.
I have NO idea how how to go about it.
Can you point me in the right direction?

You can create a class that can store larger numbers. 12345678 equals to 1234 * 10e4 + 5678.

For large numbers I use string buffers and do manual computation on it. It is much overhead and slow but you get infinite precision.

Related

Obtaining an algorithm [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
Let's say I have a variable a and b. Now I want to find a value for c such that the fraction a / c is a positive integer, and where c is as close to b as possible.
For example: a = 100 and b = 30.
In this case I want c to be 25; because a / c is an integer, and c is as close as b for which this holds.
Any ideas how I can program a function in C++ which does exactly this?
Find the factors of a. (search web for methods)
Scan resulting list for minimum difference vs b.
Is this a homework assignment? Either way, think about how you would solve this problem without writing any code. A good algorithm comes from a good design. Break the problem down into pieces and walk through some more examples. For example, how would you solve the problem of determining whether the division results in an integer value? Hint: There is a different operator you could use as opposed to division to achieve this easily. Now, how would you solve the problem of determining what number to start at for c in the algorithm? Do not write any code until you have the pseudocode figured out.

Weka analysis and predictions [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
i am doing this project that has several inputs and several outputs at the same time.
is there a way to do a prediction for more than 1 class at the same time in Weka?
any help is highly appreciated
thank you
Morning,
Weka only supports single class attributes. However, untested, I think you may be able to work around this. Try the following, I'm interested as to what kind of accuracy you get.
eg data.
BloodIron real
BloodSuger real
BloodColor real
Diabetes bool class
Lifespan real class
Using the data above, train to solve only the 'Diabetes' class. Once you have the variables enter them into your dataset and use them to solve your second 'LifeSpan' class attribute.
To increase accuracy solve the class variable with the highest entropy first.

Bindind to keys C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 8 years ago.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
Hello there I am a realative newbie when it comes to using different "commands" in order to achieve things so I was wondering if any of you know a way to bind a key to do a certain task anywhere in the programme ,so I would be able to display a function for example and after the display finishes the programme carries on normally like nothing happened and then that same key on any other push would still do the display . Thanks in advance
Plain C++ does not have any concept of "key binding". The platform (e.g., the operating system) has this knowledge and it provides some libraries to handle it. So, you must provide more information about the operating system, or use a cross-platform library like Qt.

Basic C++ Pseudo-Random Number Generation [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am learning C++ and something I would like to do is be able to generate pseudo-random numbers. I am aware that you can #include <random> however it seems as if that is still unstable (I could not get it to work.) Any help on the matter is appreciated. Thanks.
According to this question, #include <random> is a C++11 header. You might want to check if your compiler supports it, and that the proper flags are set.
Otherwise, have you looked at rand()? It should be enough for basic random numbers.

Double precision error in C++ [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Improve this question
I am using openCV C++ libraries and calculated a double. It does the arithmetic but when I read out the number, prints out -1.#QNAN on the command prompt. What does that mean?
I am using a 64-bit i3 processor.
It means you got a quiet NAN, probably by dividing -Inf / Inf or multiplying something with -Inf, or perhaps casing a non-double into a double. It's not so much a precision error as much as it's an arithmetic exception.
EDIT: or adding/substracting Inf ... read more on NaNs here
That's not an error, read more about floating point here