r/AskComputerScience • u/BigBootyBear • Jun 14 '26
Is 0.5 a facde over 1/2?
Could you say 0.5 is a facade or a pointer to 1/2? Or all numbers of the 0.n form are rational number pointers?
In my head, 0.5 seems to be pointing towards 1/2 like how 'a' points to 97 in ASCII.
*Posted in ask computer science since i'm using computer science examples which people over at r/askmath may not be familiar with.
0
Upvotes
11
u/rasmustrew Jun 14 '26
They are different representations of the same thing. 0.5=1/2 just 2 different ways of writing it.
Pointers are something else, they are some concrete object that contain a reference to some other concrete object. That could be a memory location in a computer, or it could be a piece of paper containing someones real world address.
Not sure i have heard of the facade terminology, so I won't comment to that
3
u/[deleted] Jun 14 '26
I certainly wouldn't use the word "pointer" here, as that word is used throughout computer science to mean a value that represents a memory address.
If we are speaking purely mathematically, "0.5" and "1/2" are just different ways of referring to the same rational number.
If we are speaking in terms of a programming language, when we write the value "0.5" in our source file, the compiler or interpreter does the work in representing that in binary, most often using the IEEE-754 encoding for floating point values (though some languages do have data types for rational numbers that don't use the floating point encoding). If we instead write "1.0/2.0" in the source file (I'm using explicit decimals here to make sure that it's not using integer division where 1/2=0), that will ultimately become the same value in memory, but only after actually performing the division of the two values "1.0" and "2.0"; this will either be done by the compiler before the program is ever run, generating the same code as if you had written "0.5", or at runtime if the compiler doesn't optimise this for whatever reason.
3
u/Leverkaas2516 Jun 14 '26
No. Pointers and facades are completely different concepts.
The letter 'a' doesn't point to 97. The number 97 is an integer value that can be represented in a computer's memory, on a storage medium, in a communication channel, or in a CPU register. What sometimes makes the numeric value 97 an 'a' is completely governed by the running program or application. If it's interpreted as ASCII, that's when it's an 'a'.
The number 0.5 similarly can be exactly represented as a set of bits in memory or a CPU register, when it's processed as a floating point value. The value is 3f000000 in hexadecimal. If those bits were interpreted by the running program as ASCII, the first byte would be '?' (3F is 63).
1/2 could be several things. It could be three ASCII characters '1/2', stored as three numbers (49, 47, 50). It could be the unicode character ½, stored as a numerical value 189. Or it could be the floating point equivalent of 0.5, discussed above.
7
u/Vert354 Jun 14 '26
In Computer Science "pointer" typically means a value that represents a location in memory. So no we'd never say they point to each other.
Your ASCII expample is what's called encoding. The letters have to be given number values because that's the only thing that can actually be processed.
But this wouldn't be encoding either. 1/2 isnt the "real" value and 0.5 just a convenient way to represent it. They are both the actual value.
The only time its not is for irrational or repeating decimals. In those cases the hardware uses an approximation of the value that we all agree is good enough for this purpose.
4
u/afops Jun 14 '26
It's just an encoding of a value. Specifically you'd typically use IEEE754 floats to encode your number 0.5.
This is just a standard/convention to encode values in binary. Just like the value 'a' can be encoded using ASCII as 97 (01100001).
There is nothing pointing here anywhere, just some basic conventions for how to store numbers, characters etc as binary.
"Pointers" usually refer to numbers representing memory addresses rather than values.
And "facades" is a term commonly used for a higher level concept involving types/objects/interfaces.
So no, no pointers or facades here I would say.