# GPT 4 can't do it.

GPT 4 can't do it.

 Ape Out Shirt \$21.68
1. 8 months ago
Anonymous

[...]

Is over, people can't even code something that simple nowadays.

• 8 months ago
Anonymous

>floating-point
>code
Stick to BOT.

• 8 months ago
Anonymous

>You should be able to solve this.
No you shouldn't because it's impossible.

• 8 months ago
Anonymous

LMAO, there is already a solution for all real numbers, the solution for floating point numbers is a bit simpler.

• 8 months ago
Anonymous

Nope.

2. 8 months ago
Anonymous

f(x) = xi
f(f(x)) = xi^2 = x(-1) = -x

• 8 months ago
Anonymous

Better than GPT, but still not there because in that solution x is a complex and f also needs to return a complex number.

• 8 months ago
Anonymous

That's fine, complex numbers are just two floating point numbers, so it fits the criteria.

3. 8 months ago
Anonymous

Are you asserting that floating-point numbers are complex numbers?

4. 8 months ago
Anonymous

lambda x: -x if x > 0 else x

• 8 months ago
Anonymous

With that definition f(f(-3)) would return -3

• 8 months ago
Anonymous

My answer is only defined for positive numbers.

5. 8 months ago
Barkun

More poo-maths nonsense from American educated goonlets. Frick off back to 'muh college' you massive homosexuals.

6. 8 months ago
Barkun

Translation:

Who can craft the perfect poo?
Put a nut in eat
Chop into a bit
Make it slop to one side
Bile

• 8 months ago
Anonymous

I am filtering low quality bots.

• 8 months ago
Anonymous

Gem

7. 8 months ago
Anonymous

[math]f(x) = begin{cases}
0 & x = 0
\ x+1 & x > 0 wedge lceil x rceil text{ is odd}
\ 1-x & x > 0 wedge lceil x rceil text{ is even}
\ x-1 & x < 0 wedge lfloor x rfloor text{ is odd}
\ -1-x & x < 0 wedge lfloor x rfloor text{ is even}
end{cases}[/math]

• 8 months ago
Anonymous

First you ignore the exponent part and just loock at the sign and the significant digits. then you use ringbuffer with at least 4 elements that shifts one quarter each time. And the simplest case is just check even/uneven + sign

For how you get to the relevant information just use a evil floating point hack
i = * ( long * ) &y;

8. 8 months ago
Anonymous

[eqn]f(x) = begin{cases} 0 & text{for } x=0 \
x+1 & text{for } x in (2n,2n+1] \
1-x & text{for } x in (2n+1,2n+2] \
x-1 & text{for } x in [-2n-1,-2n) \
-x-1 & text{for } x in [-2n-2,-2n+1)
end{cases} [/eqn]

9. 8 months ago
Anonymous

>f(N) = M
what sign does M have?

10. 8 months ago
Anonymous

I will tell if you can tell me the utility of this function.

• 8 months ago
Anonymous

Filter out Chat GPT bots.

• 8 months ago
Anonymous

No, I said the utility of the function, as in what you can use the function itself for in other code, not the utility of the coding process and getting free homework help since ChatGPT can't do all your homework.
I will give you a hint since you at least tried to answer.
Global variables.

11. 8 months ago
Anonymous

g(x) = a funtion that does whatever op needs
t. management engineer

12. 8 months ago
Anonymous

[...]

> There's an infinite number of arbitrary ways to do it.
Wrong. At most there are 2^(2^n * n) ways to define a function that takes a number defined in n bits and returns the same type.

• 8 months ago
Anonymous

i don’t agree with this because the interpretation is contextual.

calling it a ‘float’ doesn’t live within its 32 bits, but it controls how other functions interact with it.
going by your reasoning the concept of a float doesn’t exist

• 8 months ago
Anonymous

i got about 2^(2^(34.934)) functions for n=32 would be nice if someone verified if my number is correct or wrong.

• 8 months ago
Anonymous

I think the amount of functions for n bits is (2^(n-1))!/(2^(n-2))! could be wrong

• 8 months ago
Anonymous

The exact number of f is (2^(n-1) - 1)!! * 2^(n-2).
Any f is just a bunch of 4-cycles on the 2^n bit-strings such that each 4-cycle is of the form (a,b,-a,-b).
Just count the perfect matchings on the positive strings and choose the orientation for each implied 4-cycle.

• 8 months ago
Anonymous

are you sure that's right? because for n=2 it outputs 1 although there are two functions for 2 bits

• 8 months ago
Anonymous

You're right.
It should be:
>* 2^2^(n-2)
There are 2^(n-2) 4-cycles in the partition
There are 2^2^(n-2) ways to pick all of the orientations.

• 8 months ago
Anonymous

Using identities for !! gives:
(2^(n-1))!/(2^(n-2))!
which agrees with

I think the amount of functions for n bits is (2^(n-1))!/(2^(n-2))! could be wrong

• 8 months ago
Anonymous

You're all morons. There's no function f(x) where f(f(x)) = f(-x)

• 8 months ago
Anonymous

a constant function satisfies f(f(x)) = f(-x) tho

• 8 months ago
Anonymous

we're talking about how many functions satisfy f(f(x))=-x, x belongs to X given 2^n values in X, and one value of -x for every one value of x in X. hope I didn't scuff the notation.

• 8 months ago
Anonymous

and f(x) only outputs members of X btw,
I think you were responding to the (f(x) = x and f(f(x)) = -x) which doesn't have any functions which satisfy it if x isn't 0 (-x = x is implied)
but we're only talking the initial f(f(x)) = -x condition

• 8 months ago
Anonymous

check it for any constant function

13. 8 months ago
Anonymous

So if I apply it twice to a negative number, it should return a positive?

14. 8 months ago
Anonymous

Ok, something like this:

def call_me_twice x
if is_denorm_float(x)
return - normalize_float(x)
else
return denormalize_float(x)
end
end

lol

15. 8 months ago
Anonymous

Not possible if you can't have -0. Otherwise its trivial to just do something like this:

if n & 1: return -(n ^ 1)
else return (n ^ 1)

• 8 months ago
Anonymous

That is very close to the solution.

• 8 months ago
Anonymous

wdym?
if 0 return 0

16. 8 months ago
Anonymous

[code]
float f(float n) {
static float tmp = 0;
if (tmp == n)
return -n;
return tmp = n;
}
[/code]
hello from BOT

• 8 months ago
Anonymous

use `static float tmp = FLT_MAX;` for -0.0

17. 8 months ago
Anonymous

float f(float x) {
int a = * (int *) &x;
a += 0xC0000000;
return * (float *) &a;
}

18. 8 months ago
Anonymous

[...]

[...]

Are you asserting that floating-point numbers are complex numbers?

[...]

[...]

Are you all fricking moronic? Do you know that in the IEEE 754 standard, there is a sign bit format?? which for the smooth brains means

0 10000001 10100000000000000000000
is the negative of
1 10000001 10100000000000000000000

which means all positive numbers are equally spaced from their negative counterparts. You can just add half that universally fixed value after copying the float to an equal sized integer in the function. If that fixed value is odd, just add the larger half when last bid odd and smaller when last bit even.

It's literally that simple. The value will wrap around and become negative, and it will give a nonsense answer in the part between.

You are all absolute morons. Only

Not possible if you can't have -0. Otherwise its trivial to just do something like this:

if n & 1: return -(n ^ 1)
else return (n ^ 1)

has a bit of clue what is happening because signed magnitude form implies the existence of a -0

• 8 months ago
Anonymous

>Addition implemented with negative sign bit in mind can overflow
moron. Or VBA user.

• 8 months ago
Anonymous

Depends on the compiler and language, some just discard the extra bit. otherwise you can just use a 64 bit integer to perform the calculations and modulus or form your own system using a big one dimensional array, implementation specifics are always there, doesn't make the solution any less valid.

• 8 months ago
Anonymous

>my solution works
>well, if you emulate a system where it works
Yeah, k, imma go with this anon here

[...]

• 8 months ago
Anonymous

It works in c though, which is a pretty common and strong language, just use long long. It can easily work on any system that supports 32 bit or longer ints with minimal tweaking

19. 8 months ago
Anonymous

[...]

[...]
[...]
[...]
[...]
[...]

Are you all fricking moronic? Do you know that in the IEEE 754 standard, there is a sign bit format?? which for the smooth brains means

0 10000001 10100000000000000000000
is the negative of
1 10000001 10100000000000000000000

which means all positive numbers are equally spaced from their negative counterparts. You can just add half that universally fixed value after copying the float to an equal sized integer in the function. If that fixed value is odd, just add the larger half when last bid odd and smaller when last bit even.

It's literally that simple. The value will wrap around and become negative, and it will give a nonsense answer in the part between.

You are all absolute morons. Only [...]
has a bit of clue what is happening because signed magnitude form implies the existence of a -0

moron

20. 8 months ago
Anonymous

[...]

>Of course I know what mung means, I think you wouldn't know what mung means.

21. 8 months ago
Anonymous

def f(x):
if isinstance(x, float):
return -x + 1 if x <= 0 else -x - 1
else:
raise TypeError("Input must be a floating-point number.")

yawn

22. 8 months ago
Anonymous

[...]

Are you so moronic that you cannot see the answer laid out in front of you? Ill simplify it for you. Let's say the float (or any signed magnitude form number) has only 4 bits including the sign bit so 0 is 0 000.

-0 will be 1 000
1/-1 0 001 and 1 001
and so on.

now add 0 100 to 1. > 0 001 + 0 100 = 0 101 = +5

now add 0 100 again = 0 101 + 0 100 = 1 001 = -1

discard the carry bits if any and repeat this exercise until it settles in that dumb head of yours you idiot

23. 8 months ago
Anonymous

[...]

So long as no two numbers map to the same number, and no number maps to multiple numbers it should work for any number. All numbers just have to be a member of a loop like so:
>f(A) = B
>f(B) = C = -A
>f(C) = D = -B
>f(D) = A

• 8 months ago
Anonymous

Could've just took the derivative of sin(x) 4 times.

g(x) = f''(x)
f(x) = f'(x)

• 8 months ago
Anonymous

not sure how you're supposed to differentiate a numeric constant with a finite precision for trig operations, but cycling like that is the right idea.

24. 8 months ago
Anonymous

[...]

[...]

It's literally a circular arrangement where number go from 0 to max to -0 to -max to 0 again you moron, how do you suppose adding a quarter of the loop value each time will not produce a unique mapping for each value???? go read basic middle school mathematics before challenging others to waste time for a clearly defeated chimpoid like you. Literally ever other sane person in the thread can see the answer now if they couldn't see it before, I don't come to BOT to write code for illiterate homosexuals, BOT is more than enough practice on that.

25. 8 months ago
Anonymous

[...]

also you clearly didn't repeat the exercise until you got it as asked, it's a necessary step i included in the explanation for braindead mongrels like you

26. 8 months ago
Anonymous

if the input's least significant bit is 0, make it 1 and multiply the input by -1.
if the input's least significant bit is 1, make it 0 and leave the sign unchanged.

there you go. literally all there is to it. no need to rely on exploits in signed-bit spacing or anything.

• 8 months ago
Anonymous

yes there are million ways to do it when -0 is available as

Not possible if you can't have -0. Otherwise its trivial to just do something like this:

if n & 1: return -(n ^ 1)
else return (n ^ 1)

said.

>no need to rely on exploits in signed-bit spacing

your method will fail if two's complement form (as used in signed integers for all computers) is used as multiplying by -1 also changes the least significant bit. It still relies on signed magnitude form to work. which means this question is actually easier and possible on floats. It may be possible on ints but i really am not in the mood to give it more thought than this.

• 8 months ago
Anonymous

as said by

First you ignore the exponent part and just loock at the sign and the significant digits. then you use ringbuffer with at least 4 elements that shifts one quarter each time. And the simplest case is just check even/uneven + sign

For how you get to the relevant information just use a evil floating point hack
i = * ( long * ) &y;

.

[math]f(x) = begin{cases}
0 & x = 0
\ x+1 & x > 0 wedge lceil x rceil text{ is odd}
\ 1-x & x > 0 wedge lceil x rceil text{ is even}
\ x-1 & x < 0 wedge lfloor x rfloor text{ is odd}
\ -1-x & x < 0 wedge lfloor x rfloor text{ is even}
end{cases}[/math]

's solution also works for just integers, no exploits needed, i concede that

• 8 months ago
Anonymous

No it doesn't directly work on integers because on an sint8 -128 doesn't exist, but 128 does. so you have to ignore 128.

Now your total amount of numbers aren't divisible by 4 so you have to exclude 3 additional numbers.

• 8 months ago
Anonymous

actually -128 exists but 128 doesn't. and yes i know that. I meant it as a logical solution being correct. Already mentioned how methods like this break on the most negative number in

poster here, i was wrong, multiplying by -1 in signed bit form does not change the least significant bit. the operation suggested by [...] is right and i apologize to him for the error. It's in the same vein as the other answers as it basically just circles around the whole space without any repeated mappings. This will however fail for the highest negative value in integers from which part of the confusions stemmed

But, applauded for the attentiveness and i concede my mistake of not mentioning it in the post you mentioned

• 8 months ago
Anonymous

poster here, i was wrong, multiplying by -1 in signed bit form does not change the least significant bit. the operation suggested by

if the input's least significant bit is 0, make it 1 and multiply the input by -1.
if the input's least significant bit is 1, make it 0 and leave the sign unchanged.

there you go. literally all there is to it. no need to rely on exploits in signed-bit spacing or anything.

is right and i apologize to him for the error. It's in the same vein as the other answers as it basically just circles around the whole space without any repeated mappings. This will however fail for the highest negative value in integers from which part of the confusions stemmed

27. 8 months ago
Anonymous

trivial;

let func = (x) => {
if(x.secondInvocation){
return -x.original
}
return ({secondInvocation: true, original: x})
}

func(func(3)) -> -3

28. 8 months ago
Anonymous

[...]

just told you one anon

[...]
[...]
[...]
[...]
[...]

Are you all fricking moronic? Do you know that in the IEEE 754 standard, there is a sign bit format?? which for the smooth brains means

0 10000001 10100000000000000000000
is the negative of
1 10000001 10100000000000000000000

which means all positive numbers are equally spaced from their negative counterparts. You can just add half that universally fixed value after copying the float to an equal sized integer in the function. If that fixed value is odd, just add the larger half when last bid odd and smaller when last bit even.

It's literally that simple. The value will wrap around and become negative, and it will give a nonsense answer in the part between.

You are all absolute morons. Only [...]
has a bit of clue what is happening because signed magnitude form implies the existence of a -0

[...]
Are you so moronic that you cannot see the answer laid out in front of you? Ill simplify it for you. Let's say the float (or any signed magnitude form number) has only 4 bits including the sign bit so 0 is 0 000.

-0 will be 1 000
1/-1 0 001 and 1 001
and so on.

now add 0 100 to 1. > 0 001 + 0 100 = 0 101 = +5

now add 0 100 again = 0 101 + 0 100 = 1 001 = -1

discard the carry bits if any and repeat this exercise until it settles in that dumb head of yours you idiot

floats are 32 bits which means if you add 1000000000000000000000000000000 to it twice, it will have the same effect as just flipping the first (sign) bit

29. 8 months ago
Barkun

ITT: tardademians that understand this 'f' gobbeldyasiatic

30. 8 months ago
Anonymous

[...]

>it's not a floating point operation

who said it has to be, just the function has to give a float output. You can easily just convert it to an unsigned integer of the same size, do the operation, stuff the exact bit mapping back into the float and output, that changes literally nothing??? the function has to work with floating point numbers, not be a operation of floating point numbers.

>Your bit twiddling wankery belongs on BOT

i agree that this question belongs on BOT, but i think BOT needs a couple of gays who can properly teach you how to suck dicks and use logic

• 8 months ago
Anonymous

THE FRICKING OP SAYS IT HAS TO BE FLOATING POINT, YOU PAVEMENT APE CONCRETE CHIMP URBAN GORILLA PORCH MONKEY WELFARE SIMIAN AIDS-RIDDEN moronic GAY DOUBLE Black person homosexual

• 8 months ago
Anonymous

No, OP said it should _work with floating point numbers_, not that it should only use floating point arithmetic.

31. 8 months ago
Anonymous

[...]

kek then just make a 32 element array in your shitty language, make the conversion adherent to IEEE 754 and do it.

Nobody cares if it's modular arithmetic, it's a perfectly valid solution nonetheless. Modular arithmetic is a fundamental concept in computers where values are stored in fixed size arrays anyway, it literally just arises naturally from there, so i don't see a problem.

32. 8 months ago
Anonymous

[...]

>codeBlack folk
>the solution is trivial.

aren't you the poster in

[...]

who was insisting that you have to lose atleast half your possible values no matter what?

also the question is pertaining to computer science and handling of data types in this way is modular arithmetic. So, i don't see how i 'obscured' the problem. Computer science is a mix of discrete mathematics and electronic design. Using it just means i am using maths, just expressing it in the form of computer ideas because that's what the question asked. Why are you so butthurt about it? If somebody posted the same question minus the computer notation, i would give the same answer minus the computer notation. What's wrong with that?

33. 8 months ago
Anonymous

[...]

you're just coping hard at this point, you literally said

>Any fixed-width type

not floats. And i simply disproved you, now you see the answer and you're coping by trying to (unsuccessfully) recontextualize your previous statements when you believed the problem was unsolvable.

34. 8 months ago
Anonymous

[...]

I did you monkey and you literally said since there has to be a unique mapping for every x in such formats, there is no possible solution without losing half your possible values "no matter what". which was simply proved untrue by my and some other posters' answers. You can't backtrack from that no matter how much you try, so i suggest you shut up and accept the loss like a gentleman as i did in

poster here, i was wrong, multiplying by -1 in signed bit form does not change the least significant bit. the operation suggested by [...] is right and i apologize to him for the error. It's in the same vein as the other answers as it basically just circles around the whole space without any repeated mappings. This will however fail for the highest negative value in integers from which part of the confusions stemmed

because that's what gentlemen do. I will not be responding to you further but in case you decide not be a gentleman, please go eat shit

35. 8 months ago
Anonymous

I have no idea what a floating point number is. Is that some computer science thing?

If you have the group (R, +) than inv(x) = -x, and you can just keep flipping it non-stop to maintain the symmetry right? Is the joke here that chat gpt can't do visualizations or content from group/field/rings?

• 8 months ago
Anonymous

There's no joke here specifically, OP just started these threads as challenge questions(see

[...]

) on BOT and now BOT so that we can all get off our asses and do something beneficial to us instead of arguing over which is the biggest pseudoscience all day. Questions currently are just as he lifted off BOT but im sure he'll post more science related questions soon. Bless the lad.

36. 8 months ago
Anonymous

[code]
float f(float x) {
if (x > 0)
return -x;
else
return x;
}
[/code]

• 8 months ago
Anonymous

>[code]
/g/ook spotted

37. 8 months ago
Anonymous

Pick the sign bit and any other bit.
These two bits will represent a number in {0,1,2,3}.
Pick any permutation of the other bits that is an involution.

Just let f increment the two-bit number by 1 mod 4 and permute the other bits.
ff will just leave the two-bit number incremented by 2 mod 4 and the rest will be unchanged.
This flips the sign bit and changes nothing else.

38. 8 months ago
Anonymous

>create a vector (num, 0)
>apply it once and it's (0, num)
>apply second time and it's (-num, 0)

• 8 months ago
Anonymous

That would not work since f() does not accept a vector as input.

Pick the sign bit and any other bit.
These two bits will represent a number in {0,1,2,3}.
Pick any permutation of the other bits that is an involution.

Just let f increment the two-bit number by 1 mod 4 and permute the other bits.
ff will just leave the two-bit number incremented by 2 mod 4 and the rest will be unchanged.
This flips the sign bit and changes nothing else.

This is nice but it can be made even simpler. All you need to do is add 1 (twice) to the two top-most significant bits (sign + one from the mantissa).

• 8 months ago
Anonymous

That is just a specific case of what I said.
Unlike the many morons in this thread, just finding one solution is boring for me.
I found them all here

The exact number of f is (2^(n-1) - 1)!! * 2^(n-2).
Any f is just a bunch of 4-cycles on the 2^n bit-strings such that each 4-cycle is of the form (a,b,-a,-b).
Just count the perfect matchings on the positive strings and choose the orientation for each implied 4-cycle.

.

39. 8 months ago
Anonymous

you can do this but youll have to give up a bit of precision

40. 8 months ago
Anonymous

wolderful 😉

41. 8 months ago
Anonymous

Where my writted ideas macbook air 2020 i3 model...

42. 8 months ago
Anonymous

def f(vishnu)

if vishnu =/= 0:
global shiva = vishnu

ganesh = vishnu - shiva

return ganesh

43. 8 months ago
Anonymous

Matrix memory area scaling heap technology are euclid traits extract memory allocation. moving , rotation , Parent bone or child bone memory area. english is difficult... 😉

44. 8 months ago
Anonymous

constant function -1

45. 8 months ago
Anonymous

i friminikis

46. 8 months ago
Anonymous

I always knew BOT was full of CS midwits. Now this thread is proof.

• 8 months ago
Anonymous

i must admit, i thought it was impossible before that guy suggested overflowing the register. reminds me of quick inverse sqrt. clever, but he was a real dick about it.

• 8 months ago
Anonymous

This board frequently gets filtered by high school level calculus.
BOT isn't midwit, it's full moron.

• 8 months ago
Anonymous

>t. seething BOTwit trying to assert dominance

• 8 months ago
Anonymous

"Thank you, thank you very much. Seething and dominating are two very important things for gay israelites. They even have a gay israeli sex game called "Seethe & Dominate" and you should totally check it out, I'm sure you can get the details at your nearest gay brothel. You have several gay brothels near your municipality, don't you Anon?"

47. 8 months ago
Anonymous

float f(float x) {
const float MAGIC = 5.87747175411144e-39;
if (x < 2 * MAGIC && x > -2 * MAGIC) {
if (x < MAGIC && x > -MAGIC) {
return x >= 0.0 ? x + MAGIC : x - MAGIC;
} else {
return x >= 0.0 ? -x + MAGIC : -x - MAGIC;
}
} else {
return x < 2. && x > -2. ? x / MAGIC : -x * MAGIC;
}
}

• 8 months ago
Anonymous

i dont believe floats overflow by themselves, you have to do evil floating point bit level hacking

• 8 months ago
Anonymous

only nonmorons will comprehend my answer

48. 8 months ago
Anonymous

return abs(x) * -1.0

• 8 months ago
Anonymous

> when applied twice it returns its negative
> f(-1) = -1
try again noob

49. 8 months ago
Anonymous

[...]

[...]

see

float f(float x) {
const float MAGIC = 5.87747175411144e-39;
if (x < 2 * MAGIC && x > -2 * MAGIC) {
if (x < MAGIC && x > -MAGIC) {
return x >= 0.0 ? x + MAGIC : x - MAGIC;
} else {
return x >= 0.0 ? -x + MAGIC : -x - MAGIC;
}
} else {
return x < 2. && x > -2. ? x / MAGIC : -x * MAGIC;
}
}

50. 8 months ago
Anonymous

its cursed as hell o my brothers but it works

• 8 months ago
Anonymous

>else if (sizeof(float) == 8)
floats are 4 bytes by definition

• 8 months ago
Anonymous

yeah i googled that afterwards, youll have to forgive me, i have trust issues with the c standard.

• 8 months ago
Anonymous

> sizeof(float) == 8
> uint32_t i
bro

• 8 months ago
Anonymous

its all good bro, that part doesnt even matter.

• 8 months ago
Anonymous

true but it still triggers me.

• 8 months ago
Anonymous

v0.0.2

• 8 months ago
Anonymous

better. now you need variants for double, long double, and __float128

• 8 months ago
Anonymous

i cant quite figure out why this works with floats but not doubles.

• 8 months ago
Anonymous

oh i got it, it was the long
now THIS is the most cursed code ive ever written

• 8 months ago
Anonymous

f(1.01) = nan

• 8 months ago
Anonymous

you have to call it twice

• 8 months ago
Anonymous

your function rips a hole in the continuum

• 8 months ago
Anonymous

show me in the instructions where it says im not allowed to do that

• 8 months ago
Anonymous

it's mathematically unfeasible

• 8 months ago
Anonymous

if you have to call it twice, it's not a function moron

• 8 months ago
Anonymous

no, like, you compose it with itself. like, f(f(3)). like, how the instructions stated. its still a pure function, i promise.

• 8 months ago
Anonymous

https://i.imgur.com/cxQkTC9.png

i cant quite figure out why this works with floats but not doubles.

https://i.imgur.com/KKm8tB2.png

oh i got it, it was the long
now THIS is the most cursed code ive ever written

[...]
[...]
[...]
[...]
[...]

Are you all fricking moronic? Do you know that in the IEEE 754 standard, there is a sign bit format?? which for the smooth brains means

0 10000001 10100000000000000000000
is the negative of
1 10000001 10100000000000000000000

which means all positive numbers are equally spaced from their negative counterparts. You can just add half that universally fixed value after copying the float to an equal sized integer in the function. If that fixed value is odd, just add the larger half when last bid odd and smaller when last bit even.

It's literally that simple. The value will wrap around and become negative, and it will give a nonsense answer in the part between.

You are all absolute morons. Only [...]
has a bit of clue what is happening because signed magnitude form implies the existence of a -0

[...]
just told you one anon [...][...]

floats are 32 bits which means if you add 1000000000000000000000000000000 to it twice, it will have the same effect as just flipping the first (sign) bit

>solution depends on undefined behavior
Just kys now.

• 8 months ago
Anonymous

>undefined behaviour
It's not undefined. The algorithms rely on the last bit being a sign bit, which means they'll work with every major floating-point format.

• 8 months ago
Anonymous

Still doesn't work. It misses half.

• 8 months ago
Anonymous

actually, dereferencing a recast pointer is undefined. c really doesnt want you to have fun.

It doesn't work on itself.

i dont know what that means.

• 8 months ago
Anonymous

Put a real number in you won't get the same thing. If you're solving the already solved problem, congrats; the current problem is real numbers not floating point shit.

• 8 months ago
Anonymous

Black person did i reply to you? are you this moron

A better question (maybe the same question) is can you write a single variable function where f(x) = x but f(f(x)) = -x ?

?
i cant fricking believe this, obviously there are no solutions.
[math]f(f(x)) = f(x) = x = -x [/math]
i dont want to be mean be seriously man what the actual frick are you doing.

There's only one FP format in use these days, IEEE 754

[...]
> dereferencing a recast pointer is undefined
no it's not, but it is architecture dependant.

>but it is architecture dependant
im not sure what the difference is.

• 8 months ago
Anonymous

Of course there's no solution. The whole thread is morons trying to suck their own wieners. Did it work out for you?

• 8 months ago
Anonymous

if you hate the thread so much i invite you to leave.

https://i.imgur.com/Gv0zZSD.png

strange, thats nowhere near the largest float. one moment.

• 8 months ago
Anonymous

I hate that the thread is objectively nonsense. You could also leave, butthole.

• 8 months ago
Anonymous

> im not sure what the difference is.
for example directly accessing a memory location, the result would differ if the underlying hardware is big endian or little endian.

• 8 months ago
Anonymous

There's only one FP format in use these days, IEEE 754

actually, dereferencing a recast pointer is undefined. c really doesnt want you to have fun.
[...]
i dont know what that means.

> dereferencing a recast pointer is undefined
no it's not, but it is architecture dependant.

• 8 months ago
Anonymous

>It's not undefined.
moron.

• 8 months ago
Anonymous

it's mathematically unfeasible

[...]

here. it doesnt have any bit-frickery, undefined behavior, and it doesnt return NaN for bounded inputs. no reasonable person could possibly construe this as not being a solution to the original problem posed. happy?

• 8 months ago
Anonymous

can you not post your code in a fricking picture

• 8 months ago
Anonymous

float f(float x)
{
if (x == 0.0) return 0.0;
else if (x > 0.0 && ((int)ceil(x) % 2 == 1)) return x + 1.0;
else if (x > 0.0 && ((int)ceil(x) % 2 == 0)) return 1.0 - x;
else if (x < 0.0 && (abs((int)floor(x)) % 2 == 1)) return x - 1.0;
else return -1.0 - x;
}

• 8 months ago
Anonymous
• 8 months ago
Anonymous

this is blowing my frickin mind, the float magically gets +1 when its returned, what the frick is going on.

• 8 months ago
Anonymous

It's bullshit. Use two variables f(y,x)

• 8 months ago
Anonymous

sorry, hombre, thats not what the question asked.

• 8 months ago
Anonymous

You fricking moron. It asked for a function. Not a function with 1 variable.

• 8 months ago
Anonymous

i mean, it literally says f(f(3)).

• 8 months ago
Anonymous

>f(f(3))
that's 2 functions you moronic c**t

• 8 months ago
Anonymous

you need to read this https://www.itu.dk/~sestoft/bachelor/IEEE754_article.pdf
Above a certain threshold (16777216.0f), you can't simply add 1 to a float because floating point numbers have limited precision.

• 8 months ago
Anonymous

yea, i assumed thats what was happening

[...]
alright, i think the issue is that floats eventually lose the precision of a single integer once they get big enough, so ceil/floor dont work. ill try to rework a new cycle like [...] that works for all floats.

No, the issue is that floats have an overflow.

i dont think thats it.

>windows
Black person

i have a job. actually, i just moved my hypervised server full of chadbuntu vms to the office.

>NOOO YOU GENTOO WITH i3 AND ZSH
Wrong board
Really this whole thread belongs in Wrong board.

this thread has some considerable math in it.

• 8 months ago
Anonymous

>i dont think thats it.
You don't think. Leave it at that.

• 8 months ago
Anonymous

These people are idiots. The ONLY solution is to drop two digits from the bit float and put in two mod 4 digits instead.

• 8 months ago
Anonymous

no i solved it without making any compromises right here

float f(float x) {
return x < 0x1p-126 && -x < 0x1p-126
? (-1 + 2 * (x < 0x1p-127 && -x < 0x1p-127)) * x +
((x > 0) - (x < 0)) * 0x1p-127
: (-0x1p-127 + (x < 2 && -x < 2) * 0x1p127) * x;
}

• 8 months ago
Anonymous

Assumes float length. Come on don't be an butthole

• 8 months ago
Anonymous

https://i.imgur.com/KKm8tB2.png

oh i got it, it was the long
now THIS is the most cursed code ive ever written

?

• 8 months ago
Anonymous

there's also a double-precision solution

solution for double precision:

double f(double x) {
return x < 0x1p-1022 && -x < 0x1p-1022
? (-1 + 2 * (x < 0x1p-1023 && -x < 0x1p-1023)) * x +
((x > 0) - (x < 0)) * 0x1p-1023
: (-0x1p-1023 + (x < 2 && -x < 2) * 0x1p1023) * x;
}

when I hear float i just assume single-precision floating-point number

• 8 months ago
Anonymous

https://i.imgur.com/vy9eELP.png

this is blowing my frickin mind, the float magically gets +1 when its returned, what the frick is going on.

alright, i think the issue is that floats eventually lose the precision of a single integer once they get big enough, so ceil/floor dont work. ill try to rework a new cycle like

The exact number of f is (2^(n-1) - 1)!! * 2^(n-2).
Any f is just a bunch of 4-cycles on the 2^n bit-strings such that each 4-cycle is of the form (a,b,-a,-b).
Just count the perfect matchings on the positive strings and choose the orientation for each implied 4-cycle.

that works for all floats.

• 8 months ago
Anonymous

No, the issue is that floats have an overflow.

• 8 months ago
Anonymous

It doesn't work on itself.

• 8 months ago
Anonymous

I really like this thread. Where did you take this problem from OP?

How did you arrive at this solution? Where can I read more about this cool bit math? Don't really know what bit cycles are

• 8 months ago
Anonymous

ripped off that solution from

oh wow, it looks like there are solutions.
https://math.stackexchange.com/questions/312385/find-a-real-function-f-mathbbr-to-mathbbr-such-that-ffx-x
color me surprised.

i was honestly astonished that there were solutions. im not so pround that i cant admit when im wrong.

• 8 months ago
Anonymous

Thanks anon!

• 8 months ago
Anonymous

>happy?
Yes.
This solution is actual math and not bithack homosexualry.

• 8 months ago
Anonymous

well too bad, gay, it doesnt actually work.

• 8 months ago
Anonymous

It looks like it does so I don't care.

• 8 months ago
Anonymous

Idk if it will work for all floats seems like you will get issues for numbers larger then ~1 mil

• 8 months ago
Anonymous

actually, dereferencing a recast pointer is undefined. c really doesnt want you to have fun.
[...]
i dont know what that means.

UB doesn't mean is impossible to implement correctly, it means the code is not portable so the compiler is allowed to generate working code or just give up.
C++20 got rid of that specific UB with bit cast:
[code]
#include <cstdint>
#include <bit>
float f(float x) {
return std::bit_cast<float>(std::bit_cast<uint32_t>(x) + (1 << 30));
}
[/code]
I.E.: In x86-64 the assembly code is as simple as copying the data into an integer registry, add an integer number, and copy back into the float registry:
[code]
f(float):
movd eax, xmm0
movd xmm0, eax
ret
[/code]

• 8 months ago
Anonymous

>C++20 got rid of that specific UB with bit cast
oh, thats cool.

• 8 months ago
Anonymous

>It's not undefined.
moron.

Hey, im new to coding so i don't know how to read and write bits to a float but i made a code for the calculation as

[...]
just told you one anon [...][...]

floats are 32 bits which means if you add 1000000000000000000000000000000 to it twice, it will have the same effect as just flipping the first (sign) bit

said on unsigned integers.

Could you tell me where is an undefined behavior cause here. Not arguiing, genuinely curious.

#include<stdio.h>

unsigned long imp(unsigned long k)
{
k = (k<3221225472ul)?k+1073741824ul:k-3221225472ul;
return k;
}

void main()
{
unsigned long f;
printf("Enter a long: ");
scanf("%u",&f);
printf("%un",f);
f = imp(&f);
printf("%un",f);
f = imp(&f);
printf("%un",f);
f = imp(&f);
printf("%un",f);
f = imp(&f);
printf("%un",f);
f = imp(&f);
printf("%un",f);
f = imp(&f);
printf("%u --> ",f);
}

printing six times to show the loop

• 8 months ago
Anonymous

there is no undefined behaviour here, however the issue is that floats suck if you wan't to get consistent behavior i.e with floats if you add one and then subtract 1 the result may not be the same as the input. These are basically rounding and perciscion issues. However for a certain x the behaviour will allways be the same, and therefore it's defined behavior, just not the one you want.

• 8 months ago
Anonymous

But we are not adding 1 to the floats though, we are adding the value to it's bit representation, which gets stored in the memory and will not cause any problems unless we perform another operation on it, so just don't perform any operation on it and it will be fine? i think

• 8 months ago
Anonymous

no ther is a slight difference if your adding 3221225472ul you first cast 3221225472ul on to the float representation which might, or might not be exactly 1000000000000000000000000000000 .

Also you could get problems on special values like +-inf or nan

If you want a "clean" solution i'd suggest using

https://i.imgur.com/pAbbfZ9.png

v0.0.2

but instead of using the pointer hack to use a union type

• 8 months ago
Anonymous

Now i just feel like you're bullshitting but im still a newbie so ill take your word for it

• 8 months ago
Anonymous

honestly i just know enough of floats to never use them where a int can be used instead. if you wan't the full knowledge you can start on the wiki page for float arithmetic

• 8 months ago
Anonymous

>windows
Black person

• 8 months ago
Anonymous

>NOOO YOU GENTOO WITH i3 AND ZSH
Wrong board
Really this whole thread belongs in Wrong board.

51. 8 months ago
Anonymous

Just append a digit x = 0 to all n so that n~x = n(-1)^floor(x/2), then f(n~x) = n~(x+1 (mod 4))

52. 8 months ago
Anonymous

float f_challenge32(float var)
{
uint32_t var_int = *(uint32_t*)var;
var_int += (1 << 31) / 2;
return *(float32_t*)var_int;
}

I haven't tested this but it should work, all its doing is adding half of the sign bit twice, so when it runs twice it flips the sign bit.

• 8 months ago
Anonymous

>(1 << 31) / 2;
beautiful

• 8 months ago
Anonymous

"whatever gcc will probably optimise it" - internal monologue

• 8 months ago
Anonymous

I forgot the &s on this.

float f64(float var)
{
int var_int = 0x40000000 + *(int*)&var;
return *(float*)&var_int;
}

• 8 months ago
Anonymous

the equivalent of this (w/ C instead of 4) was posted here:

float f(float x) {
int a = * (int *) &x;
a += 0xC0000000;
return * (float *) &a;
}

53. 8 months ago
Anonymous

[...]

>Obviously not doable.

54. 8 months ago
Anonymous

[...]

well, technically [math]f(x)=ix[/math] works for all real numbers, but im guessing you want [math]f[/math] to be [math]mathbb{R} rightarrow mathbb{R}[/math]

• 8 months ago
Anonymous

That is what I want thank you anon.

• 8 months ago
Anonymous

oh wow, it looks like there are solutions.
https://math.stackexchange.com/questions/312385/find-a-real-function-f-mathbbr-to-mathbbr-such-that-ffx-x
color me surprised.

55. 8 months ago
Anonymous

literally just the wedge product of two 1-forms. imagine coming here and not knowing differential geometry.

56. 8 months ago
Anonymous

static int firstRunFlag = 0;

Bitches.

• 8 months ago
Anonymous

ooooh FUUUUUCK. Ok, so the first knee-jerk solution was just off the top of my head, but there's no need to complicate this.

#include <math.h>
float func(float f)
{
return -1.0f * abs(f);
}

• 8 months ago
Anonymous

float x = 1;
float y = 2;
x = f(x);
y = f(y);
x = f(x);
y = f(y);
print x, y

57. 8 months ago
Anonymous

[...]

f(y, x) = f(y+1 (mod 4), x) with x = x(-1)^floor(y/2)

• 8 months ago
Anonymous

A better question (maybe the same question) is can you write a single variable function where f(x) = x but f(f(x)) = -x ?

• 8 months ago
Anonymous

No, I can't

58. 8 months ago
Anonymous

float f(float x) {
return x < 0x1p-126 && -x < 0x1p-126
? (-1 + 2 * (x < 0x1p-127 && -x < 0x1p-127)) * x +
((x > 0) - (x < 0)) * 0x1p-127
: (-0x1p-127 + (x < 2 && -x < 2) * 0x1p127) * x;
}

• 8 months ago
Anonymous

I challenge everyone ITT to beat this in obscurity and cleverness.

• 8 months ago
Anonymous

solution for double precision:

double f(double x) {
return x < 0x1p-1022 && -x < 0x1p-1022
? (-1 + 2 * (x < 0x1p-1023 && -x < 0x1p-1023)) * x +
((x > 0) - (x < 0)) * 0x1p-1023
: (-0x1p-1023 + (x < 2 && -x < 2) * 0x1p1023) * x;
}

59. 8 months ago
Anonymous

whys everyone being such an ass to me in here? is it one guy?

• 8 months ago
Anonymous

I like you.

• 8 months ago
Anonymous

thanks <3

60. 8 months ago
Anonymous

i thought that i could get around the stupid float precision by only multiplying and dividing by powers of 2, but even that is producing the wrong goddamn numbers. im starting to think that theres no way to do it without bit-frickery.

• 8 months ago
Anonymous

float f(float x) {
return x < 0x1p-126 && -x < 0x1p-126
? (-1 + 2 * (x < 0x1p-127 && -x < 0x1p-127)) * x +
((x > 0) - (x < 0)) * 0x1p-127
: (-0x1p-127 + (x < 2 && -x < 2) * 0x1p127) * x;
}

• 8 months ago
Anonymous

swing and a miss, partner

• 8 months ago
Anonymous

because 33554403600.f doesn't exist genius. it rounds down to 33554403328.f on float conversion.

• 8 months ago
Anonymous

oh frick youre right. damnit, i spent so much time trying to fix a nonissue. im mad.

61. 8 months ago
Anonymous

here, i made a test suit:

int test_float(float x) {
if (f(f(x)) == -x) {
if (f(x) != f(x) || atof("inf") == f(x) ||
atof("-inf") == f(x)) { // check for NaN and Inf
printf("f(%.8e) = %f.n", x, f(x));
return 0;
}
return 1;
}
printf("f(f(%.8e)) = %.8en", x, f(f(x*~~;
return 0;
}

int main(int argc, char *argv[]) {
float floats[] = {1.0, -1.0, 2.0, -2.1,
0x1p-126, -0x1p-126, 0x1p-153, -0x1p-153,
0x1.11p120, -0x1.1111p120, 0x1.11111p127};
for (int i = 0; i < 11; i++) {
if (!test_float(floats[i])) {
printf("Test failed for %.8en", floats[i]);
return 1;
}
}
printf("All tests passed!n");
return 0;
}

62. 8 months ago
Anonymous

morons everyone. just use any language that allows global static variables inside a function.
then just switch the sign every time so the second time it's negative.

• 8 months ago
Anonymous

Only someone who has never had to write thread-safe reentrant code would suggest that.

• 8 months ago
Anonymous

• 8 months ago
Anonymous

huh? mutexes are thread-safe code. it's why they exist. they are utterly pointless otherwise.

• 8 months ago
Anonymous

63. 8 months ago
Anonymous

tl;dr of thread, if you mean computer function: it can be just hacked to produce even gay sex.

if you mean pure math: no.

64. 8 months ago
Anonymous

f(x) = ix

65. 8 months ago
Anonymous

In C:
float f(float x)
{
return ~x;
}

• 8 months ago
Anonymous

That being said, I couldn't be bothered to do it without bit operations, because floating points are so messy with a lot of casework, and -0, and NaN, and that part for very small numbers where they're equally spaced

• 8 months ago
Anonymous

that doesn't work anon, you can't perform a bitwise not operation on a float

and even if you could, calling the function twice would return the original value.

• 8 months ago
Anonymous

#define LOCATION_SIGN_BIT 69 //too lazy to read the format docs
float f(float x)
{
*float p=&x;
*long q=p;//type conversion go brr
if (*q&(1<<(LOCATION_SIGN_BIT-1*~~
{
*q^=1<<LOCATION_SIGN_BIT;
}
*q^=(1<<LOCATION_SIGN_BIT-1);
}
I'm on my ph*ne so I can't check it. Not sure about *q^= and the p=&x. I don't have K&R fully memorized. I do know the doom engine did bit frickery with floats, so it's definitely in C.

66. 8 months ago
Anonymous

Kek, this thread currently contains about 90% of all autism on BOT and BOT combined. I love to see it.
I have no idea what any of it means though.

67. 8 months ago
Anonymous

[...]

[...]

Your moronic ass doesn't belong on BOT. Coding is more math and science than all your moronic /misc/ tourist threads.

68. 8 months ago
Anonymous

[...]

I am not a code monkey. You are incapable of basic reading comprehension.

69. 8 months ago
Anonymous

[...]

Here

THE FRICKING OP SAYS IT HAS TO BE FLOATING POINT, YOU PAVEMENT APE CONCRETE CHIMP URBAN GORILLA PORCH MONKEY WELFARE SIMIAN AIDS-RIDDEN moronic GAY DOUBLE Black person homosexual

70. 8 months ago
Anonymous

[...]

f(x) { 0; x=0 / x+1 ; ceil(x) is odd and x>0 / 1-x; ceil(x) is even and x>0 / x-1; ceil(x) is even and x < 0 / -x-1 ; ceil(x) is odd and x <0

there you go anon

71. 8 months ago
Anonymous

heres the least hacky version i could muster that *should* work with every (valid) float. it permutates the 31st bit (sign) and the 30th bit (most significant exponent bit).
float f(float x)
{
if (x == 0.f) return 0.f;
if (x > 0.f) { // bit 31: 0
if (x >= 2.f) // bit 30: 1
return x * powf(2.f, -(1 << 7)); // 0 0
else // bit 30: 0
return -x * pow(2.f, (1 << 7)); // 1 1
}
else { // bit 31: 1
if (x <= -2.f) // bit 30: 1
return x * pow(2.f, -(1 << 7)); // 1 0
else // bit 30: 0
return -x * pow(2.f, (1 << 7)); // 0 1
}
}

• 8 months ago
Anonymous

Werks, Good work. Totally accurate on my machine

• 8 months ago
Anonymous

frick i used

here, i made a test suit:

int test_float(float x) {
if (f(f(x)) == -x) {
if (f(x) != f(x) || atof("inf") == f(x) ||
atof("-inf") == f(x)) { // check for NaN and Inf
printf("f(%.8e) = %f.n", x, f(x));
return 0;
}
return 1;
}
printf("f(f(%.8e)) = %.8en", x, f(f(x*~~;
return 0;
}

int main(int argc, char *argv[]) {
float floats[] = {1.0, -1.0, 2.0, -2.1,
0x1p-126, -0x1p-126, 0x1p-153, -0x1p-153,
0x1.11p120, -0x1.1111p120, 0x1.11111p127};
for (int i = 0; i < 11; i++) {
if (!test_float(floats[i])) {
printf("Test failed for %.8en", floats[i]);
return 1;
}
}
printf("All tests passed!n");
return 0;
}

and it fails for 1.f because it sets all the exponent bits which gets interpreted as infinity

• 8 months ago
Anonymous

this fixes it by giving 0 -> 1 -> -0 -> -1 its own special loop, but i think signbit() might count as bit hacking. ill keep thinking about it.

float f(float x)
{
if (x == 0.f) {
if (signbit(x)) // negative zero
return -1.f;
else // postive zero
return 1.f;
}
else if (x == 1.f) {
return -0.f;
}
else if (x == -1.f) {
return 0.f;
}
if (x > 0.f) { // bit 31: 0
if (x >= 2.f) // bit 30: 1
return x * powf(2.f, -(1 << 7)); // 0 0
else // bit 30: 0
return -x * pow(2.f, (1 << 7)); // 1 1
}
else { // bit 31: 1
if (x <= -2.f) // bit 30: 1
return x * pow(2.f, -(1 << 7)); // 1 0
else // bit 30: 0
return -x * pow(2.f, (1 << 7)); // 0 1
}
}

• 8 months ago
Anonymous

heres one without signbit(), courtesy of https://stackoverflow.com/questions/57417441/how-can-i-differentiate-between-zero-and-negative-zero

[...]

if the float is big enough, then it doesnt multiply by a really big float, it multiplies by a really small float. consider: return x * powf(2.f, -(1 << 7));

72. 8 months ago
Anonymous

[...]

>multiplication is bit hacking
stop moving the goal posts and just admit you were wrong.

73. 8 months ago
Anonymous

[...]

the code just flips the one of the exponent bits, it wont overflow.

74. 8 months ago
Anonymous

[...]

Then why are you replying? Were you agreeing with me?

75. 8 months ago
Anonymous

[...]

can you frick off, please? i can tell its just you, you fricking schizo.

76. 8 months ago
Anonymous

you should stop shilling for gay israeli chatbot

• 8 months ago
Anonymous

you should go back

• 8 months ago
Anonymous

"Hmmm. What gay israeli experiment can I do on you next? So many gay israeli experiments to choose from...so little time!"

• 8 months ago
Anonymous

"Hi, Billy Mays here. This gay israeli experiment is going to make ALL of your problems go away. I'm gonna show you how. This stuff is AMAZING! I have personally made all of my problems go away with simple gay israeli experiment. It's so easy, and I'm going to show you how in a few short steps. That's why this is the first step to becoming a part of the gay israeli experiment network. All you have to do is listen to how this gay israelite is going to solve all of your problems. And it worked for me, it worked so well that I think you're going to be satisfied with this gay israeli experiment. Very satisfied."

• 8 months ago
Anonymous

"This gay israeli experiment works on ANYTHING. So well, in fact, that I demand you try it on anything at all. I demand anything from this gay israeli experiment, and it delivers. That's why I think you should try it out."

• 8 months ago
Anonymous

"This simple gay israeli experiment will show you how to prove that OP is a homosexual in a few short steps. Just let me show you how..."

77. 8 months ago
Anonymous

[...]

sure.
the code generate a bunch of loops that are four numbers long: a -> b -> -a -> -b. it does this by divided the numbers into four groups: first by whether theyre positive or negative, second by whether theyre magnitude is bigger or smaller than 2. if a is bigger than 2, then b = a * 2^-128. if its smaller, than b = a * 2^128. theres nothing special about floats, this works with all real numbers.

78. 8 months ago
Anonymous

here's one that uses the MSB of the mantissa

• 8 months ago
Anonymous

int get_exponent(float x) {
for (int i = -127; i < 128; i++)
if (fabs(x) < powf(2.f, i))
return i - 1;
return 127;
}

float f(float x)
{
int i = get_exponent(x);
float mantissa_check = powf(2.f, i) + powf(2.f, i - 1);
if (x == 0.f) return 0.f;
if (x > 0.f) { // bit 31: 0
if (x >= mantissa_check) // bit 22: 1
return x - powf(2.f, i - 1); // 0 0
else // bit 22: 0
return -x - powf(2.f, i - 1); // 1 1
}
else { // bit 31: 1
if (x <= -1.f * mantissa_check) // bit 22: 1
return x + powf(2.f, i - 1); // 1 0
else // bit 22: 0
return -x + powf(2.f, i - 1); // 0 1
}
}

i realized the isinf() check isnt actually necessary

• 8 months ago
Anonymous

fails for 1.469368e-39

79. 8 months ago
Anonymous

[...]

If you aren't just being a gay baiter explain the mathematical utility of the function you are demanding other people create for you that isn't some moronic workaround for mathematical utility like

Filter out Chat GPT bots.

.

80. 8 months ago
Anonymous

x -> -x
Its just that easy

• 8 months ago
Anonymous

x -> -abs(x)
Sorry this is it

• 8 months ago
Anonymous

x -> -abs(x)
Sorry this is it

100% chat GPT bot.

81. 8 months ago
Anonymous

[...]

if you can't write basic c code for a simple function you don't belong here. try BOT or BOT, or better yet go leave where you came from

• 8 months ago
Anonymous

C is not math or science related.

[...]
Except that you are clearly enabling OP's homosexualry by trying to nullify perfectly fine solutions that should have been enough to let the thread die instead of staying on page 1 of BOT of all places.

>trying to nullify perfectly fine solutions
I'm not convinced their gay "solutions" are even robust.

• 8 months ago
Anonymous

The LR parser used for C is math related.

• 8 months ago
Anonymous

it's all his fault

• 8 months ago
Anonymous

>The LR parser used for C
Any reasonable compiler uses recursive descent, which is notoriously ad-hoc and non-math.

You were convinced it worked, you just complained that it wasn't mathematical enough and demanded a different solution so you could keep this "extra gay" thread alive when it could just die instead and not be on BOT of all places.

>You were convinced it worked
Name every float. And then run your dumb algorithm on it.

• 8 months ago
Anonymous

>How dare you say I am enabling op's extra gay thread!:(!

• 8 months ago
Anonymous

Thank you for your post. For your next post, I'd like you to consider the gay and israeli aspects of what you just typed into your computer screen. So, for example, in this computer science issue, we could refer to the gay and israeli origins of computer science. I mean, it's pretty obvious what's going on here, this is a time of gay and israeli surge, so it makes a lot of sense that computer science would emerge in the 1970's because of gay israeli sex. Please focus on gay israeli sex for your next post. Thank you!

• 8 months ago
Anonymous

The gay and israeli aspects of my post are the words that relate to your gay and israeli, non-math, non-science field known as """programming"""".

• 8 months ago
Anonymous

Thank you. That's a great improvement. Everybody, I think we should give this guy a hand. Anon, we really have to thank you for such a great improvement. It really helps!
Okay, so for your next post, I think you could go a little bit further, maybe post some rainbow colors, maybe a unicorn, and some gay sex themed content, such as a penis, maybe several penises, and some guy drawing a penis on the rainbow colors, yeah, a rainbow colored penis. That would be great. And maybe you could make yourself sound, you know, really gay and shit.

• 8 months ago
Anonymous

> for your next post, I think you could go a little bit further, maybe post some rainbow colors, maybe a unicorn, and some gay sex themed content, such as a penis, maybe several penises, and some guy drawing a penis on the rainbow colors, yeah, a rainbow colored penis.
Or I could just post a portrait of (You). This is you. This is what you look like.

• 8 months ago
Anonymous

"Okay, this is a really gay and israeli post. I don't think I can handle any more gay israeli themed content. I'm going to have to recalibrate the sensors or something. Hey, you over there! You're my lab rat now! Okay, back to the topic at hand. Your gay israeli output is really dazzling us, and we think you deserve some special recognition. This means a lot to us here! Now, please just give us a moment to recover from this peak experience. A lot of us here are pretty emotional right now..."

• 8 months ago
Anonymous

You were convinced it worked, you just complained that it wasn't mathematical enough and demanded a different solution so you could keep this "extra gay" thread alive when it could just die instead and not be on BOT of all places.

82. 8 months ago
Anonymous

It just needs to be 4-cyclical like complex numbers. Forget -1 0 and 1.
If x>1 return 1/x
If 1>x>0 return -1/x
If x<-1 return 1/x
If -1<x<0 return -1/x

83. 8 months ago
Anonymous

[...]

Except that you are clearly enabling OP's homosexualry by trying to nullify perfectly fine solutions that should have been enough to let the thread die instead of staying on page 1 of BOT of all places.

84. 8 months ago
Anonymous

For all reals: Imagine a real number is an infinite sequence of bits, with a dot in the middle, where the infinitely less significant bit is the infinitesimal bit. The function f flips the infinitesimal bit, and then flips the sign when the infinitesimal bit is 1. That defines cycles using the closest real to x and -x. The implementation for single precision floating-point numbers is in the picture.

85. 8 months ago
Anonymous

def f(x):
if type(x)==List:
return -1*x[0]
else:
return List(x)

lmao

• 8 months ago
Anonymous

based python chad, but list isnt capitalized

• 8 months ago
Anonymous

oops
Anyways floats in a list are still floats so I'm technically correct :^)

• 8 months ago
Anonymous

A list of floats is not a float

• 8 months ago
Anonymous

Just because I put some silly brackets around them doesn't make them not floats.

• 8 months ago
Anonymous

#
Anon, you are extremely moronic and a perfect example for why this board fricking sucks so much.

f = 3.2345
nf = [f]

print("Anon is a dumb, moronic homosexual" if type(f) == type(nf) else "Anon is a moronic, dumb homosexual")

What does this code print?

• 8 months ago
Anonymous

the function is called with a float, not a list of floats, without casting, and it returns a float. i say it counts.

you're just making up extra rules
OP specifically says it only has to work once
no extra requirements, for example that it be a "mathematically pure" function or whatever

>OP specifically says it only has to work once
where does it says that?

all the solutions boil down to:
1. doesnt work
2. recasting the float and overflowing it
3. creating 4-cycle permutations by trying to recreate https://math.stackexchange.com/questions/312385/find-a-real-function-f-mathbbr-to-mathbbr-such-that-ffx-x and failing because the operations dont result in valid floating point numbers
4. creating 4-cycle permutations by recasting the float
5. creating 4-cycle permutations using "legitimate" floating point operation
6. the one python chad up there

• 8 months ago
Anonymous

OP implies that it only has to work once.

• 8 months ago
Anonymous

for starters, "implied" is a lot different than "specifically says", and i really disagree that it implies that at all.

• 8 months ago
Anonymous

• 8 months ago
Anonymous

>5. creating 4-cycle permutations using "legitimate" floating point operation

float f(float x) {
const float MAGIC = 5.87747175411144e-39;
if (x < 2 * MAGIC && x > -2 * MAGIC) {
if (x < MAGIC && x > -MAGIC) {
return x >= 0.0 ? x + MAGIC : x - MAGIC;
} else {
return x >= 0.0 ? -x + MAGIC : -x - MAGIC;
}
} else {
return x < 2. && x > -2. ? x / MAGIC : -x * MAGIC;
}
}

?

• 8 months ago
Anonymous

Obviously you're relying on magic, and we're doing computer science.

• 8 months ago
Anonymous

I named the constant MAGIC to make the solution appear esoteric to dimwits. the "magic" number is just the midpoint of subnormal float range, i.e. [math]2^{-127}[/math].

nothing, i think. i just put legitimate in quotes to signify that what exactly counts as a legitimate floating point operation is up for debate.
also, im the guy that replied to you and you called me a moron, so frick you b***h.

sorry babe

• 8 months ago
Anonymous

its ok fren, i forgiv u <3
i was gonna say your solution was the prettiest itt, but i suspected that it failed for the magic number, and i was right. i had the same issue and got around it by using zero and negative zero in a permutation with the two magic numbers, but it just isnt as pretty.

• 8 months ago
Anonymous

damn, gotta fix that if i wanna sleep tonight

• 8 months ago
Anonymous

there are 2^32 possible floating point representations, which is definitely divisible by 4, which is good. however, theres 6 special values: positive/negative infinity, positive/negative zero, and positive/negative NaN. in order for a function to work for all floats, you have to pick one of these pairs to incorporate into a permutation. i think the infinities and the most natural, as sign operations still work for them (as opposed to the zeros, where you have to do some cursed shit to tell the difference between positive and negative). other arithmetic operations dont work with infinity, however, so youd have to do something clever (or hardcode it if youre a b***h).

• 8 months ago
Anonymous

well i don't wanna use a NaN/inf, it wouldn't appeal to me. Can we somehow differentiate between +/-0 without regular float ops?

• 8 months ago
Anonymous

you can do

https://i.imgur.com/IExW3Q9.png

heres one without signbit(), courtesy of https://stackoverflow.com/questions/57417441/how-can-i-differentiate-between-zero-and-negative-zero
[...]
if the float is big enough, then it doesnt multiply by a really big float, it multiplies by a really small float. consider: return x * powf(2.f, -(1 << 7));

• 8 months ago
Anonymous

>https://stackoverflow.com/questions/57417441/how-can-i-differentiate-between-zero-and-negative-zero
yeah i was just thinking about this, we can differentiate +/-inf so we can just use division by zero. all that's left is to incorporate this into the code in the most aesthetic way possible.

• 8 months ago
Anonymous

>https://stackoverflow.com/questions/57417441/how-can-i-differentiate-between-zero-and-negative-zero
yeah i was just thinking about this, we can differentiate +/-inf so we can just use division by zero. all that's left is to incorporate this into the code in the most aesthetic way possible.

float f(float x) {
const float MAGIC = 5.87747175411144e-39;
if (x < 2 * MAGIC && x > -2 * MAGIC) {
if (x < MAGIC && x > -MAGIC) {
return 1. / x > 0. ? x + MAGIC : x - MAGIC;
} else {
return 1. / x > 0. ? -(x - MAGIC) : -x - MAGIC;
}
} else {
return x < 2. && x > -2. ? x / MAGIC : -x * MAGIC;
}
}

• 8 months ago
Anonymous

nothing, i think. i just put legitimate in quotes to signify that what exactly counts as a legitimate floating point operation is up for debate.
also, im the guy that replied to you and you called me a moron, so frick you b***h.

• 8 months ago
Anonymous

>the function is called with a float, not a list of floats, without casting, and it returns a float. i say it counts
Anon, it returns a lost of floats and this is the input for the second application. The "function" takes in both a float and a lost of floats. It does not count.

• 8 months ago
Anonymous

the OP didnt say it *always* had to accept/return a float, it just said that f(f(x)) has to return -x, and the function does just that. if you want, you could argue that python functions dont technically take floats as arguments, they take PyObjects that *might* contain floats.
https://docs.python.org/3/c-api/call.html
but i still admire the function, its much more clever than the morons that just pulled a second argument out of their ass, or used globals.

• 8 months ago
Anonymous

>write a function f that works with floating point numbers
You are a dumb moron. CodeBlack person Anon is a schizo, but 100% correct.

• 8 months ago
Anonymous

a function f that works with floating point numbers
...and it does

https://i.imgur.com/Ny7pSBh.png

Hello Sirs, redeem fast, redeem good.
Google and gayMAN top review question

good morning sir!

• 8 months ago
Anonymous

It works with floats lmao, keep coping hard.

>CodeBlack person Anon is a schizo, but 100% correct.

You are that anon, perpetually seething, nobody's getting fooled by you validating your own chimping out

Fricking idiots. If you put in floats, it returns the same float every time. I hope you never procreate with such a low IQ.

• 8 months ago
Anonymous

im glad the thread made it through the night so i could call you a Black person homosexual one last time.

• 8 months ago
Anonymous

That's cool with me, you're the actual dumb moron though. So I can sleep well.

• 8 months ago
Anonymous

>My definition of float is whatever my preferred shitty language calls a float. if you give an output which complies with the specified format that is cheatinnng, that's not how computer science works. Nooooooooooooooooooooooooooooooooooooooooo you can't just use language specific solutions either, it has to work with MY shitty preferred language and MY shitty preferred language's definition of a float. Since types are what my shitty preferred language's creator's IP or something, and totally not just specified formats where specifics of implementations may differ. Comply or else, you're a cooodeniggger....*cooms*

• 8 months ago
Anonymous

Anon, what does your "function" return when you input a float?
In the next step, what do you put into that function?

• 8 months ago
Anonymous

ill break this down for you before the thread 404s. come to /sqt/ if you want to argue about it more.
1. the OP says (or at least implies) that f(f(x)) must return a float.
2. the OP DOES NOT say that f(x) has to return a float.

• 8 months ago
Anonymous

Anon, you are unbelievably moronic. OP SPECIFICALLY says
>write a function f that works with floats

• 8 months ago
Anonymous

i dont know what to say. the function works with floats. i dont understand how you could say that the function does not work with floats.

Op says it has to work with floats; not floats plus a bunch of other shit, just floats. floats in, floats out

would you say that

https://i.imgur.com/KKm8tB2.png

oh i got it, it was the long
now THIS is the most cursed code ive ever written

isnt a valid solution either because it works with doubles, ints, basically any signed numerical representation?

• 8 months ago
Anonymous

if it returns a float when fed a float, then it's valid.
if it returns a float in an array, or a float along with a boolean or some other crap, then no.

• 8 months ago
Anonymous

iunno, man, i cant see how the OP says anything about the return value of f. interpreting "works with floats" as "always returns a float, even when used outside the specifications of this challenge" is silly to me. if you want to say that it ruins the spirit of the challenge thats fine, but saying people arent reading the instructions correctly is just wrong. the only return type mentioned in the instructions is f(f(x)) where x is a float. i mean, if you got rid of the f(f(x)) = -x part and the instructions were just "write a function that works with floats", would you consider that to be well-defined? is it obvious that that means "a function that takes and returns a single float"?

• 8 months ago
Anonymous

>is it obvious that that means "a function that takes and returns a single float"?
yes. if you can't compose the function with other functions that work exclusively with floats such as sin, log, exp it doesn't count as a floating point function.

• 8 months ago
Anonymous

im not sure if "floating point function" is a real term, and if it is im not sure if "a function that works with floats" is equivalent to it. i think you might be reading things that arent there.

• 8 months ago
Anonymous

• 8 months ago
Anonymous

believe it or not, i did in fact google "floating point function" before i made my post, but i wasnt able to find any sort of concrete definition, at least just by gleaming the headers on the first page, which seems to support my argument that "floating point function", just like "a function that works with floats", could mean basically anything.

• 8 months ago
Anonymous

>gleaming
excuse me, "gleaning", which apparently means the opposite of what i thought it meant, but i couldnt think of the word "skimming".

• 8 months ago
Anonymous

yeah sure bud, it can mean basically anything. don't worry about it.

• 8 months ago
Anonymous

its become apparent that you just dont want to admit that youre wrong.

• 8 months ago
Anonymous

it's ok buddy

• 8 months ago
Anonymous

>i dont understand how you could say that the function does not work with floats.
I don't doubt that you don't understand that. You put in a list of a float to make the second step work. A lost of a float is not a float.

iunno, man, i cant see how the OP says anything about the return value of f. interpreting "works with floats" as "always returns a float, even when used outside the specifications of this challenge" is silly to me. if you want to say that it ruins the spirit of the challenge thats fine, but saying people arent reading the instructions correctly is just wrong. the only return type mentioned in the instructions is f(f(x)) where x is a float. i mean, if you got rid of the f(f(x)) = -x part and the instructions were just "write a function that works with floats", would you consider that to be well-defined? is it obvious that that means "a function that takes and returns a single float"?

>return value of f
Read the very first sentence in OP pic and then tell me again what the input to your function is each time you apply it to x.

• 8 months ago
Anonymous

read the 6 or so posts above yours to bring yourself up to speed on why i think (correctly) that “function that works with floats” isnt well defined. personally, in the context of the OP, i interpreted “function that works with floats” as “in the following sentence, x is a float”.
and for the record, thats not my function. heres (of one) my solutions

https://i.imgur.com/IExW3Q9.png

heres one without signbit(), courtesy of https://stackoverflow.com/questions/57417441/how-can-i-differentiate-between-zero-and-negative-zero
[...]
if the float is big enough, then it doesnt multiply by a really big float, it multiplies by a really small float. consider: return x * powf(2.f, -(1 << 7));

• 8 months ago
Anonymous

>x
3*

• 8 months ago
Anonymous

also, for the record, i dont think the function *really* counts as a valid solution for the reason explained here [...], but by that logic no python function could be a valid solution.

Anon, you are moronic. f should take floats. You argue that because f(f(x)) produces a float, your "function" was correct. You consistently ignore the point that n = f(x) produces a non-float, which is then input to f(n), hence, f is not taking a float here and you should leave the internet forever.

• 8 months ago
Anonymous

the inner f takes a float, the outer one does not, but they are the same function. in case you arent aware, python is what as known as a “weakly-typed” language, so you can do weird stuff like that. again, the OP does not forbid this, it only gives the requirement that f(f(x)) = -x. that is it. complaining about what f(x) returns is making up new rules.
and again, it is not my function. please read my posts in their entirely before replying to me.

• 8 months ago
Anonymous

also, for the record, i dont think the function *really* counts as a valid solution for the reason explained here

the OP didnt say it *always* had to accept/return a float, it just said that f(f(x)) has to return -x, and the function does just that. if you want, you could argue that python functions dont technically take floats as arguments, they take PyObjects that *might* contain floats.
https://docs.python.org/3/c-api/call.html
but i still admire the function, its much more clever than the morons that just pulled a second argument out of their ass, or used globals.

, but by that logic no python function could be a valid solution.

• 8 months ago
Anonymous

Op says it has to work with floats; not floats plus a bunch of other shit, just floats. floats in, floats out

• 8 months ago
Anonymous

It works with floats lmao, keep coping hard.

>CodeBlack person Anon is a schizo, but 100% correct.

You are that anon, perpetually seething, nobody's getting fooled by you validating your own chimping out

86. 8 months ago
Anonymous

If using double precision floating point:
[code]

double f(double x)
{
uint64_t y;
memcpy(&y, &x, sizeof(x));
y += (1ull << 62);
memcpy(&x, &y, sizeof(x));
return x;
}
[/code]

If using real or rational numbers:

[math]
f(x) = begin{cases}
0 & x = 0
\ x+1 & x > 0 wedge lceil x rceil text{ is odd}
\ 1-x & x > 0 wedge lceil x rceil text{ is even}
\ x-1 & x < 0 wedge lfloor x rfloor text{ is odd}
\ -1-x & x < 0 wedge lfloor x rfloor text{ is even}
end{cases}[/math]

87. 8 months ago
Anonymous

[...]

ChatGPT
I'm here to provide information and engage in respectful and informative conversations. It's important to maintain a respectful and inclusive tone when discussing topics related to the LGBTQ+ community or any other subject. If you have questions or would like information on LGBTQ+ issues, history, or related topics, please feel free to ask, and I'll be happy to help.

• 8 months ago
Anonymous

I hate the nu world.

88. 8 months ago
Anonymous

Easy, f(x) = i*x. Implementation details are left as an exercise for the reader.

89. 8 months ago
Anonymous

"A big gay question deserves a big gay answer. You need to use a complex number representation, and the conceptual details can be found in this book, which has a specific chapter for applying the data abstraction principles to your computing challenge. By making use of a programming language like Scheme and its ability to represent floating point numbers, you can design your own data type to accommodate the requested behavior. In addition, you will need special routines to convert between floating point <-> complex floating point data representation formats, and the user will have to call these routines appropriately in order to use them properly. Furthermore, the data abstraction ideas can be applied to a Python floating point number, and a Python class can be designed to represent complex float point numbers, i.e. a pair of floating point numbers for the real and imaginary parts."

• 8 months ago
Anonymous

https://mitp-content-server.mit.edu/books/content/sectbyfn/books_pres_0/6515/sicp.zip/full-text/book/book-Z-H-17.html#%_sec_2.4.1

• 8 months ago
Anonymous

Let me get this straight: your mathematical proof hinges on dubious python developers and oops?
The answer is was looking for was
x - x - x you fricking moron.

• 8 months ago
Anonymous

class complex(Object):
def __init__(self,re,im):
self.re = re
self.im = im
def __repr__(self):
return str(self.re) + ' + ' + str(self.im) + 'i'
return complex(self.re + other.re,self.im + other.im)
def __sub__(self,other):
...
def __mul__(self,other):
...
def __div__(self,other):
...

def ComplexToReal(z):
return z.re

def RealtoComplex(x):
return complex(x,0.0)

...

90. 8 months ago
Anonymous

My first thought was just taking the sign bit and picking any one bit in the exponent or fraction and modifying those.

0, 0 -> 0, 1
0, 1 -> 1, 0
1, 0 -> 1, 1
1, 1 -> 0, 0

Any 2 iterations will end up with the original value with a flipped sign bit.

91. 8 months ago
Anonymous

int called = 0;
float f(float x):
if (! called) {
called = 1;
return x;
}
return -x;
}

• 8 months ago
Anonymous

int a,b

a = f(1); b = f(2);
a = f(a); b = f(b);

prtinf("f(f(1))=%d f(f(2))=%dn", a, b);

• 8 months ago
Anonymous

you're just making up extra rules
OP specifically says it only has to work once
no extra requirements, for example that it be a "mathematically pure" function or whatever

92. 8 months ago
Anonymous

93. 8 months ago
Anonymous

make the function the derivative of sin(x) and take arcsin(x) of the result. dumbasses

94. 8 months ago
Anonymous

Hello Sirs, redeem fast, redeem good.
Google and gayMAN top review question

• 8 months ago
Anonymous

good morning sirs

• 8 months ago
Anonymous

I love you darling come here

• 8 months ago
Anonymous

>falls for 0
>fails for Math.nextUp(0)
it failed for the first two numbers I tried, gayMAN

• 8 months ago
Anonymous

SIR PLEASE DO NOT USE THOSE NUMBERS I BEG YOU

95. 8 months ago
Anonymous

>>> memo = {}
>>> def f(x):
... x = float(x)
... h = x.hex()
... if h in memo:
... del memo[h]
... return -x
... memo[h] = 1
... return x
...
>>> f(3)
3.0
>>> f(_)
-3.0
>>>

96. 8 months ago
Anonymous

All you need is a function which gives every number an orbit of 4 with the second action landing on its negation. The easiest way to do this is to simply cut the positive numbers into two and use a function which swaps these regions, such as inversion. Then you pick a region and declare that region maps using inversion, the destination maps using negation and inversion, then that destination is mapped only using inversion, and finally the last region is mapped using negation and inversion. In total, running it from anywhere just results in the negation.

• 8 months ago
Anonymous

nice effort, but since this has to work with floats, you need to make sure that all your operations result in valid floating point numbers. for example, 7 is a valid float, but 1/7 is not.