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
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
a processor that doesn't support mutliplications is shit
Any processor does not support it. It supports electric charges xD
Alignant
Supports -> has an operation for it (in my case)
BinaryByter
Any processor does not support it. It supports electric charges xD
it needs an operator that converts the binary representation of numbers as electrical charges into their multiplied version
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
but really, you should stop thinking of datatypes as a "thign"
you thinking that a string or complex number might be a "thing" on hardware level shows your lack of understanding
⚛ Hz
I think data type should be considered as a abstract layer
Alignant
you thinking that a string or complex number might be a "thing" on hardware level shows your lack of understanding
It MIGHT be a thing on a hardware level. Multiplication is a hardware thing on a modern processor, but it's a software thing on 8086
Alignant
vectors are a thing on GPUs
BinaryByter
please stop talking
Alignant
Okay... is float a thing to a processor that can operate with it? 😢
Alignant
STRINGS; COMPLEX NUMBERS ARE NOT A THING
Btw, I know it's not a thing. I was telling it's not a thing *-*
Dima
sse gpu lol
数学の恋人
how can I get output of double variable having value = -5279235.721231465 the same instead of -> -5.27924e+06
数学の恋人
use std::cout « std::fixed;
oh sorry I forgot you told the same earlier also
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)?
⚛ Hz
So how did you do
数学の恋人
see
please help here
⚛ 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
数学の恋人
see
It's okay I got it
Alignant
see
what does your program do?
⚛ Hz
Why would you ever need that? 😢
Because some legacy interfere only accept a function pointer
数学の恋人
what does your program do?
Nothing just takes input and then outputs
Alignant
⚛ Hz
Nothing just takes input and then outputs
So why not just using string
数学の恋人
What does the test do?
Checks whether the output is same as expected or not
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
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
Result: 1 0 -5.27924e+06 -5.27924e+06
floating point error:>