How do you negate a bitwise complement of a Double in Swift 4?
In particular, I'm trying to convert the following (trvial) javascript line to Swift:
var j = -~(0.707 * x);
Using it as is gives the error message "Unary operators may not be juxtaposed; parenthesize inner expression".
Ok, I don't like that either. So, I tried:
var j = -(~(0.707 * x)) //Compile error: "Unary operator '~' cannot be applied to an operand of type 'Double'".
Then:
var j = -(~((0.707 * x).bitPattern)) //Compile error: "Unary operator '-' cannot be applied to an operand of type 'UInt64'".
And then:
var j = -Int64(~((0.707 * x).bitPattern)))
which compiles but crashes with "Fatal error: Not enough bits to represent a signed value"
Eventually, I found myself standing on my head rubbing my belly and sticking pins in a doll bought in Louisiana while sacrificing a frozen chicken.