is there an easier way to unset a double-precision value's sign bit?
if you're not a complete idiot, you won't be using a double.
Name:
Anonymous2008-09-27 22:12
>>3
What if he needs 64 bits enterprise precision?
Name:
Anonymous2008-09-27 22:13
value &= (~(1<<(sizeof(double)*8-1)));
Name:
Anonymous2008-09-27 22:32
OP here.
>>5
i can't use that. value has to be double-precision and bitwise operators don't work on doubles.
Name:
Anonymous2008-09-27 22:48
Hey guys, do you think maybe the folks who wrote your absolute value implementation thought about this already and either (a) implemented it efficiently or (b) realised it was never going to matter?
>>7
i looked at MinGW's source code for cmath and they call the function __builtin_fabs which (according to the comments in the file) is supposed to be defined by the compiler.
where can i find the implementation for GCC's __builtin_fabs?
Name:
Anonymous2008-09-27 23:14
>>9
Because looking at the compiler's dirty bits is faster than benchmarking it yourself? If you think so, google it.
/* @(#)s_fabs.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
>>10
actually, the code in >>1 doesn't work. so now i just wanna see how it's done.
Name:
Anonymous2008-09-27 23:40
INSTRUCTION SET REFERENCE, A-M
FABS—Absolute Value
Opcode Instruction 64-Bit Compat/ Description
Mode Leg Mode
D9 E1 FABS Valid Valid Replace ST with its absolute value.
>>18
You don't know that! He could be a respected leader of a large data center that
spends all of its time calculating the absolute value of floats. For all you
know they spend half their cycles in that very function. The servers don't even
have a floating point unit! This could save his company millions in electricity
alone, and net him a big fat bonus to take home to his wife and kids, and take
them to the zoo, because he doesn't have to stay late at work anymore to watch
his computer farm crunch row after row of digits, turning minus to plus. That
does matter, Anonymous. It really does matter.
>>22
Ah, so this is how abs() works. It connects to >>1's servers, uploads the number, and then downloads the absolute value! Thank you, >>1, for providing a service to the millions of computer users around the world.
>>1
You do realize that you're comparing doing a couple of operations on bits to calling the constructor of a STL class, then doing those bit operations, calling methods of the previously created object which means wasting a lot of ram uselessly then performing a typecast in an overly obfuscated line of code, right ?
>>1
Wow. This is truely expert programmer quality. Always treat the compiler designers as incompetent shitnuggets and write your own OMG OPTIMIZED solutions. Paying attention to the efficiency and complexity of your own code is secondary. You guys should start writing malloc() and new implementations of your own to keep yourselves as far as possible from any real work.
Name:
Anonymous2008-10-02 15:08
>>48
OP will be an asset to the Anonix development effort.
Name:
Anonymous2008-10-02 15:25
>>49
Negative, the OP uses bloated C++ standard library.