Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Turn negative into positive
Message
From
09/12/2013 14:59:46
 
 
To
09/12/2013 14:00:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01589528
Message ID:
01589604
Views:
51
>>
>N = N-2*N  && this will do it but is there simply a function that will convert it.
>>This assumes two's complement representation of integers and will fail on systems where you're dealing with one's complement representation. And if you think that sounds weird, in one's complement you can have positive and negative zero. Recall running into that once before on a Control Data mainframe when I had a Pascal program that called a routine written in FORTRAN and got weird results (code generated by the Pascal compiler assumed that zeroes were being normalized, whereas FORTRAN code tended to leave zero values non-normalized. Problem was easily fixed by calling an assembly-language routine that normalized values).
>>
>>And of course, changing a negative to a positive could be a simple matter of perspective. (^_-) ๐Ÿ˜‰ ๐Ÿ˜œ
>
>I'm sorry - I don't see where the two's complement representation comes in. It's just arithmetic

Whoops. Ended up misreading the formula (ended up seeing bit operations for some reason)... Darned myopia coupled with astigmatism (takes off "coke-bottle-lens" glasses to wipe lens clean, while squinting at screen)... with a touch of sleep deprivation... (okay,.. at least I'm not sleeping depraved...) Time for more caffeine! ( http://www.endalldisease.com/nasa-studies-spiders-injected-with-marijuana-caffeine/ )

Of course... that formula you gave has a risk of numeric overflow...
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform