Questions tagged [numbers]

For questions relating to any data type that is numerical. This may include integers, rational numbers, floating-point, fixed-point, and large numbers.

Filter by
Sorted by
Tagged with
20 votes
10 answers

What are the drawbacks of allowing implicit boolean/integer conversions?

Some languages (C, C++, JavaScript, Python) allow one to use integers as booleans and vice versa: int x; if (x) // Equivalent to: x != 0 y(); Or: ...
24 votes
10 answers

What are some advantages/disadvantages of having built-in syntax to represent numbers in non-decimal bases?

(For this question, I'm referring to integers. This question also assumes the language still uses base two internally, even if to the programmer it appears as base ten - this question is about syntax)....
8 votes
6 answers

What are the disadvantages of not handling big numbers?

What are the disadvantages of not being able to handle huge numbers also knows and an Integer limit like in JS? I know it's not a super common thing to run into problems like that while programming so ...
18 votes
7 answers

What are the advantages and disadvantages of implementing reals as rationals?

(By rationals, I mean fractions. So, 0.5 would be stored as 1/2.) There's only one language I know of which does this. So, what ...
12 votes
5 answers

What are the pros and cons of fixed-point arithmetics vs floating-point arithmetics?

From Wikipedia: In computing, fixed-point is a method of representing fractional (non-integer) numbers by storing a fixed number of digits of their fractional part. ... More generally, the term may ...
11 votes
6 answers

What are the downsides of having types for floats and integers?

What are the downsides to having different data types for floats and integers instead of just a number data type? I know that having different ones can improve memory usage. But are there any ...
10 votes
1 answer

How are significant digits implemented?

When working with engineering data, it is often important to know the number of significant digits of numbers. However, decimal numbers in languages I've encountered so far don't seem to include this ...
5 votes
5 answers

How could fixed-point be implemented?

Fixed point is essentially storing a number of units of a certain size instead of storing a significand and an exponent. However, if the units could be of any size, how big would the fixed-point units ...
4 votes
1 answer

Implementing a number to string semantics efficiently in a C-style language?

In C our options for converting numbers to strings and adding them to a string are limited to: Write your own function. sprintf() to a buffer. Either way, one ...
12 votes
6 answers

What are the disadvantages of this far-fetched idea: All integers can be treated as boolean arrays?

I do not know of any languages that support this idea but I just thought that since numbers are just bits, why should we not be able to access those bits directly? In most languages such as C or C++, ...