Semplificato il valore assoluto senza bitshift a caso

This commit is contained in:
La Programmatrice Verde 2024-11-29 09:08:55 +01:00
parent 6ef3c92bfe
commit 9999126ab6
9 changed files with 9 additions and 4 deletions

View File

@ -107,8 +107,13 @@ class Program
return p_numero*p_numero;
}
static int CalcolaValoreAssoluto(int p_numero){
const int costante1=31;
return (p_numero + (p_numero >> costante1)) ^ (p_numero >> costante1);
const int costante1=-1;
if (p_numero<0){
return p_numero*costante1;
}
else{
return p_numero;
}
}
static bool VerificaNumeroPari(int p_numero){
if (p_numero%2==0){

Binary file not shown.

Binary file not shown.

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("miscellanea")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+7ba7b81980177f67f02957fc7927b07fbe320f9e")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+6ef3c92bfe1fa9cd10a726a95ec35692e9855fc5")]
[assembly: System.Reflection.AssemblyProductAttribute("miscellanea")]
[assembly: System.Reflection.AssemblyTitleAttribute("miscellanea")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
03707c09f63468c9a7dd5dc5b526deca7119451a9080efc2c2b4f585d9ef2bcd
33feeae87dc5512a07eb6a72f4a4558f1e8099bdd9ccbacaa2fbb2ff25e3a368

Binary file not shown.

Binary file not shown.

Binary file not shown.