Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Turn negative into positive
Message
De
09/12/2013 14:23:58
 
 
À
09/12/2013 14:00:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01589528
Message ID:
01589595
Vues:
38
>>
>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

but not to your machines CPU. Even in longints you have 1 number not working accordingly. And with floats the problem lies in the binary representation of the "2" and rounding errors.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform