TRENDING NEWS

POPULAR NEWS

A Question About Infinity Programming And Storing It

How do programmers deal with infinities?

Programmers deal with infinities by devising proper data checks and employing error checking and catching mechanism in correct places inside the code.Very often the mathematical expressions evaluate to infinity (positive or negative) due to incorrect user input. We catch the error to make sure the system doesn’t break and let the user know what went wrong. They can fix the mistake and try again.In some cases, infinities can occur due to numerical imprecisions of computer’s way of storing numbers. Again, make sure the system doesn’t crash, write a thorough error report and let users know what it’s not their fault and whom they need to contact.There is an alternative way of dealing with failures in numerical computation. Some languages allow operator overloading. If an operation fails, it’s possible to return a special object which will represent a failure, while still supporting mathematical operations on itself. In that case, the error propagates to the end of the calculation, and the system presents the users with a message signaling a problem during the evaluation.Always make sure your users get informative feedback, regardless of what happens.

How can I store an infinity value in a Python variable?

We can definitely store an infinity value in a Python Variable.In the below example we have assigned infinity value to a “num” variable using inf as a parameter to the float() function.We can also store negative infinity as a value in a same wayAnother method for assigning infinity value to a variable is through using “import math”.isinf() function is used to determine whether a specific number is an infinite number or not.Hope it helps.Happy Coding

What is the way to represent infinity in a programming language?

Yes and no.The IEEE floating point math standard (which defines how floating point numbers are stored in binary on almost all modern computers) has a specific binary representation for infinity:IEEE 754 - WikipediaThe standard actually has separate values for infinity and negative-infinity - and there are also values for “Not-a-Number” (“NaN”) for things like 0/0 which are undefined.This is the way the underlying hardware implements infinity.I’m not aware of any languages that have a way to specify infinity as a symbol within the language - but most have a function or macro you can call that returns the special bit pattern that the hardware recognizes and processes as “infinity”.So, for example, in C there is a constant called ‘INFINITY’ defined in math.h. But you cannot just type an infinity symbol on the keyboard (hold down the ALT key and type 236 on the number pad) and expect the C compiler to understand it.float x = ∞ ; // ILLEGAL!
float y = INFINITY ; // LEGAL!
…and if you try this:#include
#include

int main ()
{
float x = INFINITY ;
printf ( "To %f and beyond!\n", x ) ;
return 0 ;
}
…you’ll probably be disappointed to get:To inf and beyond!

However, doing math on a computer using infinities like this is not generally recommended because these numbers are more often considered as error returns than as actual computable entities…and most software that deals with floating point numbers will not cope with infinity as you’d expect mathematically.

Can a hard-disk with infinity storage be made?

Currently the storage device with the highest amount of memory is the ‘yet to be unveiled’ seagate’s 60 TB SAS SSD… This is a sign that the storage capacity is increasing year by year, but we’re not there yet to make an “infinite storage”…Everything is limited when it comes to computers… Even the world’s most expensive CPU with more than 40 cores has a certain set of limitations… So a storage with no limit is not easy to make…But we couldn’t decide that a thing like that is impossible… Right now, we are living in the AI era where the tech legends are trying to make lifeless machines smarter than humans… If someone successfully makes a system which works like human brain, then it means it can store unlimited amount of data…After all, digital data is nothing but a combinations of just two binary digits 0 & 1… If a storage device could make files by just replicating and combining this binary digits in different forms, any file could be represented and stored with no limit… and instead of focusing on making components bigger and expensive, I think manufacturers should focus on making the resources small and efficient…If a 30 minute lossless 4K video file occupies only 2 MB of storage, then there would be no need for a 60 TB storage at all… The HBO SITCOM Silicon Valley clearly reveals the fact that with a highly efficient lossless file compression technique we could reduce the cost of all the things including storage space, bandwidth hand so on…It is not completely impossible, but don’t expect it to happen in the near future…—it assistors

Why should we store a function parameter value in a class private variable?

Well, the ultimate idea of object-oriented paradigm is that, you should keep all the data (variable) required for an operation (function/method) available and collected in one place. Also you should keep all the operations (functions/methods) that uses the above mentioned collection of data in one place. Apparently this one place is a CLASS!. Now that you've collected the data and you have a specific list of operations, you have to prevent any other operation, which YOU have not specified, from manipulating the collected data, hence you make the data PRIVATE!. Now that it's private, you can't access it even to store new values in it, so you define a function, to which you pass a value, and that function saved it into you variable.

Is there a computer capable of running numbers from 1 to infinity?

No. For two reasons.First, you need to be able store the numbers you are manipulating. Infinity requires infinite storage space. Even if we used every single atom in the universe to store a bit of information, that is still far short of what's needed to represent infinity.Second, there is no "up to infinity". That doesn't make sense. Again, by definition, infinity is something you can never get to. There is no number which, if you add 1 to it, will become infinity.

How can I set a variable value as -infinity in C?

Just like that,#include
...
double f = -INFINITY;
or, if you have a particularly prehistoric compiler,double f = -HUGE_VAL;
INFINITY - cppreference.comHUGE_VAL - cppreference.com

How do I create a program in Java that calculates the sum from 1 to n (1 + 2 + …+ n) where n is a variable?

The bug in your code is your code  has print statement inside the loop. public static void main(String[] args) {

int n = 100;
int sum = 0;

for (int i = 0; i <= n; i++) {
sum = sum + i;

}

System.out.println(sum);
}This should work.Alternative solution:You can also use direct formulasum=(n\2)*(1+n) /**
*
* @author nitin
*/
public class sum {
public static void main(String args[]){

int n=100,sum=0;

sum=n*(1+n)/2;
System.out.println("Sum is "+sum);


}
}
This solution has constant O(1) time complexity.

How do I clear a variable on my TI-83 plus graphing calculator?

Please don't listen to the first guy, that will clear ALL your RAM and you will be very sad if you have any unarchived programs, just a warning. As for the variable, Go to 2nd + (mem), mem management, all, scroll down to your variable and hit "DEL" This won't rid your calculator of being able to store variable X, so don't worry.

TRENDING NEWS