Skip to main content
32 votes
Accepted

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

Floating-point vs rational representation Advantages of rational representation: Precision: rational numbers are exact. 1/7 prints as ...
tarzh's user avatar
  • 3,779
30 votes

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

The main drawback of allowing implicit boolean/integer conversions is, it makes it impossible to prevent errors that result from confusion of a boolean and an integer. Next time you confuse the order ...
Eldritch Conundrum's user avatar
29 votes
Accepted

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

One advantage is bitwise arithmetic. Bitwise arithmetic is much easier to understand in bases with a power of 2 radix such as hexadecimal. Here it is fairly clear that I am masking out every other ...
CPlus's user avatar
  • 8,251
24 votes
Accepted

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

There is a particular drawback of allowing implicit conversions (aka coercions*) from bool to int in dynamic languages such as ...
kaya3's user avatar
  • 18.8k
19 votes

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

In a domain where a specific base is used, it is clearer if the code can reflect this and still be efficient. For example, airplane transponders use base 8, and colours are often represented in base ...
Adám's user avatar
  • 3,138
14 votes

What are the disadvantages of not handling big numbers?

Applications of "big numbers" The last paragraph of my answer to Did the 2019 discovery of O(N log(N)) multiplication have a practical outcome? gives some examples of cases in which large ...
Nike Dattani's user avatar
13 votes
Accepted

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

I wouldn't store them as arrays, but you can certainly implement such a syntax efficiently. If you translate x[0] to x & 1 ...
ruarq's user avatar
  • 146
9 votes

What are the disadvantages of not handling big numbers?

The question asks a double negative, so I'll answer the simpler question of what advantages there are to supporting big numbers. To me, the main benefit is peace of mind ─ sure, my auto-incrementing ...
kaya3's user avatar
  • 18.8k
9 votes

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

The other answers so far have exclusively focused on advantages. There are two disadvantages I can think of, though neither is really a strong enough reason to exclude this feature from a language. ...
kaya3's user avatar
  • 18.8k
9 votes

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

The main upside of floating-point arithmetic is that it allows for reprensenting a wider range of magnitudes than a fixed-point number using the same number of bits, while also allowing for more ...
kaya3's user avatar
  • 18.8k
9 votes

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

Booleans may not just be 1 or 0 Much of this depends on the underlying representation of the value. My particular experience of this is with C. Before C99, there was no boolean type, only integers ...
Graham's user avatar
  • 281
8 votes

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

It would encourage inefficient code 90% of the time when you're doing individual bit lookups on an int, you're doing something "wrong". E.g., this would encourage those who don't feel ...
Rydwolf Programs's user avatar
8 votes

What are the disadvantages of not handling big numbers?

"Super common" is a relative thing; I don't often use large numbers in my code, but I know people who do. It mostly depends on what your language is meant to be used for; tiny esoteric ...
Ginger's user avatar
  • 2,619
8 votes

What are the disadvantages of not handling big numbers?

Actual high-magnitude numbers aren't usually needed, but precision is much more often an issue, and the two often go together. For example, using 64-bit floats to represent money amounts can quickly ...
Adám's user avatar
  • 3,138
8 votes

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

I am implementing a language that uses rationals by default. Let me tell you why. The other answers are correct that performance and memory use are worse with rationals. My rationals are 32 bytes ...
Gavin D. Howard's user avatar
8 votes

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

In addition to all the other fine answers, Boolean coercions are not consistent across languages: Zero (0) is considered falsy in Python and JavaScript, but truthy ...
Nayuki's user avatar
  • 181
7 votes

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

Why not both? That is, make your “real” type a variant that can store either an exact rational or an approximate floating point value. You could make rational the “default”, in that literal ...
dan04's user avatar
  • 1,879
7 votes

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

Runtime safety With syntax like 0x1A50 instead of parseInt("1A50",16) you can make sure at compile time that ...
kouta-kun's user avatar
  • 1,359
6 votes

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

Strictly speaking, an "array" is a specific kind of data structure where elements are stored at contiguous, equally-spaced memory addresses. The smallest addressable unit of memory is ...
kaya3's user avatar
  • 18.8k
6 votes

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

The main advantage of having a number type is simplicity and ease of use. Many versions of BASIC just had floating point numbers, which reduced the size of the code (given that the first home computer,...
prosfilaes's user avatar
6 votes
Accepted

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

It's not a common case, but integral data types (sometimes known as shorts and longs) allow for integer overflow, which may be used by clever programmers (if the programming language allows it). E.g. ...
Glorfindel's user avatar
  • 1,493
6 votes

What are the disadvantages of not handling big numbers?

Almost none Most major programming languages, like C#, Java and as you mentioned, JavaScript, don't support arbitrary large integers in their default namespaces/packages/... However, for all of those ...
Glorfindel's user avatar
  • 1,493
6 votes

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

Fixed point arithmetic is more consistent Adding 0.128 to a number will always add 0.128 to the number until you reach the limit. In floating point arithmetic the steps get more inconsistent the ...
mousetail's user avatar
  • 8,219
6 votes

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

Firstly, consider fixed-point decimal arithmetic vs. fixed of floating point binary: the former is suitable for precise representation of monetary values, while the latter shall never be used for such....
SK-logic's user avatar
  • 1,310
6 votes

How could fixed-point be implemented?

Fixed-point is an integer with a statically-known decimal (or more generally, statically-known divisor). You can represent a fixed-point datatype as an "representation" integer type and &...
tarzh's user avatar
  • 3,779
6 votes

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

One particularly bad issue with int to bool conversions is that if you have an expression based language, the assignment x=7 will typically return ...
Oscar Smith's user avatar
5 votes

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

The problem with having only a single number type is: which number type do you pick? For a good example of what not to do, you have to look no further than the most widely-used (depending on ...
Jörg W Mittag's user avatar
5 votes

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

Advantages Rationals can exactly represent a much wider range of numbers. One-third would be finitely representable. Floating point errors would be unheard of. Disadvantages It is computationally ...
Seggan's user avatar
  • 2,663
5 votes

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

It privileges one form of bit access over others Accessing a word as a bit vector can be useful in some circumstances, but even more useful is the ability to pack and unpack general bit fields. Things ...
Pseudonym's user avatar
  • 4,676
5 votes

How could fixed-point be implemented?

Make precision part of the type I’m not familiar with any general-purpose languages that use fixed point at all, but this is what PostgreSQL does. If you want to indicate that a column stores 15 ...
Bbrk24's user avatar
  • 8,927

Only top scored, non community-wiki answers of a minimum length are eligible