Skip to main content

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
24 votes
10 answers
1k views

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)....
cocomac's user avatar
  • 575
20 votes
10 answers
5k views

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: ...
CPlus's user avatar
  • 8,261
18 votes
7 answers
1k views

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 ...
The Thonnu's user avatar
  • 1,508
12 votes
6 answers
421 views

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++, ...
CPlus's user avatar
  • 8,261
12 votes
5 answers
2k views

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 ...
justANewbie's user avatar
11 votes
6 answers
549 views

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 ...
Ethan's user avatar
  • 377
10 votes
1 answer
178 views

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 ...
l0b0's user avatar
  • 199
8 votes
6 answers
678 views

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 ...
Ethan's user avatar
  • 377
5 votes
5 answers
560 views

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 ...
CPlus's user avatar
  • 8,261
4 votes
1 answer
218 views

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 ...
CPlus's user avatar
  • 8,261