Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Turn negative into positive
Message
De
10/12/2013 10:52:56
 
 
À
10/12/2013 10:31:18
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:
01589680
Vues:
51
>>>
>>>Of course... that formula you gave has a risk of numeric overflow...
>>
>>The formula I gave was
>>
>>N = -N
>>
>>
>>I find one exception where the negative value results in the same value.
>>
>>I'm not convinced overflow comes in
>>
>>(1) the value is -2^31 and (2) you force the value to be contained in a 4 byte signed integer
>>
>>n = 0x80000000
>>?'n = ', n	&& 2147483648
>>?'-n = ', -n	&& -2147483648
>>n = bitor(n, 0) && force a 4 byte signed integer
>>?'bitor = ', n	&& -2147483648
>>x = -n
>>?'-n = ', x	&& -2147483648
>>?'abs', abs(n)	&& -2.1474E+9
>>
>>? ' x == -x ', x == -x  && TRUE
>>
>>
>>
>>Update - and yes - I know why
>
>Sorry. Wasn't paying attention to who I was responding to. I should've made it clear that I was meaning the formula as given by the original poster:
>
N = N - 2*N
>was the one with the problem.

I wouldn't mind - happens to all of us



>
>Think I'll need more caffeine (opens fresh can of coffee -- takes spoon and begins munching away -- too impatient to wait for brewing batch -- besides, why dilute it with water?)
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform