BinaryByter
the compiler does know the type
Alignant
Okay, let's put it this way.
floats and ints are stored in a different way
And multiplied in a different way
exponents are being added, mantissas are being multiplied
Alignant
Therefore a processor is instructed that multiplying a float is different from multiplying an int
BinaryByter
BinaryByter
BinaryByter
it is told to do something
BinaryByter
it doesnt do somethign because it is a float
BinaryByter
the compiler actively must tell the processor to use the float registers for floating point operations
⚛ Hz
In x64 abi float should use XMM(0-7) register when pass it to function (if the arguments' number lass than 8
Alignant
it is told to do something
I mean that flags, ints and floats are types supported by hardware. Processors work with flags (jnz, lol)
They work with ints
And they work with floats
Unlike strings, complex numbers, etc. They are not supported by a processor
Alignant
And by "stored in a different way" i mean that 2 and 2.0 have different binary representation
BinaryByter
finally you make sense
Alignant
I was telling that floats, flags and ints are natively supported by a processors, while longs, long longs, string is something that only makes sense on a software level
BinaryByter
dafaq
BinaryByter
no
Alignant
Processors work with 0 an 1? :c
BinaryByter
yep
BinaryByter
the processor does nothing but convert electric states to other electric states
BinaryByter
btw: the sizes of an int and a float aren't important for the processor
Alignant
We need to agree on some terminology
I mean "supports floats" like... there were processors that did not support multiplication
Alignant
BinaryByter
Alignant
Supports -> has an operation for it (in my case)
BinaryByter
better?
BinaryByter
but really, you should stop thinking of datatypes as a "thign"
Alignant
better?
Much better :D
Okay, then...
Processors have operators for integerts, floats and flags
And don't have operators for strings, complex numbers, pointers, so on
Alignant
BETTER??
BinaryByter
⚛ Hz
I think data type should be considered as a abstract layer
BinaryByter
Alignant
vectors are a thing on GPUs
BinaryByter
BinaryByter
please stop talking
Alignant
Okay... is float a thing to a processor that can operate with it? 😢
Dima
sse gpu lol
数学の恋人
how can I get output of double variable having value = -5279235.721231465 the same instead of -> -5.27924e+06
BinaryByter
BinaryByter
数学の恋人
BinaryByter
BinaryByter
atleast not without implementing floats yourself
BinaryByter
or using gmp
BinaryByter
floats have a problem with presicion
BinaryByter
they are saved in exactly this way: -5.27924e+06
BinaryByter
and you cannot be precise enough for everything like that
数学の恋人
Actually the hackerrank compiler is not letting me pass as I was giving output that way
Alignant
maxi is ignoring me 😢
BinaryByter
I am
数学の恋人
⚛ Hz
Did anyone tried to create function pointer from a function object(like std::function)?
BinaryByter
⚛ Hz
So how did you do
数学の恋人
⚛ Hz
I found a way to get it work(convert std function to a pointer), but only available in Linux and x64 architecture, I want to get a more general solution https://gist.github.com/codehz/922b1a758618f6e87f777e88ba60a298
Alignant
数学の恋人
Alignant
what does your program do?
Alignant
⚛ Hz
Alignant
How does it compare? 😉
数学の恋人
数学の恋人
maybe they are comparing my output with theirs in form of strings
Alignant
There are some general means to compare doubles. You can't just compare them like a == b
Alignant
So I was wondering
Alignant
Alignant
A scientific string is not equal to a fixed string :D
数学の恋人
`Lol I told you IDK
Alignant
Do you know why this happens? :D
Alignant
#include <iostream>
int main() {
double a =-5279235.721231465;
double b = a;
std::cout << (a == b) << "\n";
b += a*2;
b -= a*2;
std::cout << (a == b) << "\n";
std::cout << a << " " << b << std::endl;
return 0;
}
Alignant
Result:
1
0
-5.27924e+06 -5.27924e+06
Ariana