CP-36392: Cast operands of divisions to not lose precision

Cast to `decimal` or `float` to keep floating-point precision

Signed-off-by: Danilo Del Busso <Danilo.Del.Busso@citrix.com>
This commit is contained in:
Danilo Del Busso 2021-10-04 16:22:29 +01:00
parent dcbaf5d1a4
commit db2c00d54d
No known key found for this signature in database
GPG Key ID: 55F556F9A25CB037
7 changed files with 13 additions and 14 deletions

View File

@ -1500,7 +1500,7 @@ namespace XenAdmin.ConsoleView
if (this.Size.Height >= (displayBorder ? this.DesktopSize.Height + BORDER_PADDING + BORDER_PADDING : DesktopSize.Height))
{
this.dy = (this.Size.Height - this.DesktopSize.Height) / 2;
this.dy = ((float) this.Size.Height - this.DesktopSize.Height) / 2;
}
else
{
@ -1518,7 +1518,7 @@ namespace XenAdmin.ConsoleView
if (this.Size.Width >= (displayBorder ? this.DesktopSize.Width + BORDER_PADDING + BORDER_PADDING : DesktopSize.Width))
{
this.dx = (this.Size.Width - this.DesktopSize.Width) / 2;
this.dx = ((float) this.Size.Width - this.DesktopSize.Width) / 2;
}
else
{

View File

@ -300,7 +300,7 @@ namespace XenAdmin.Controls
}
case VerticalAlignment.Middle:
{
Y = (this.Height - this.Padding.Vertical) / 2;
Y = ((float) this.Height - this.Padding.Vertical) / 2;
break;
}
case VerticalAlignment.Bottom:

View File

@ -2498,7 +2498,7 @@ namespace XenAdmin.Controls.XenSearch
if (intQuery == null)
return;
queryElement.numericUpDown.Value = intQuery.query / multiplier;
queryElement.numericUpDown.Value = (decimal) intQuery.query / multiplier;
}
}

View File

@ -213,13 +213,12 @@ namespace XenAdmin.Dialogs
into g
select new { ExpiryDate = g.Key, Hosts = g };
expiryGroups = expiryGroups.OrderBy(g => g.ExpiryDate).ToList();
if (expiryGroups.Count() <= 1)
return false;
if ((expiryGroups.ElementAt(1).ExpiryDate - expiryGroups.ElementAt(0).ExpiryDate).TotalDays > 30)
return true;
if(expiryGroups.Count() > 1)
{
expiryGroups.OrderBy(g => g.ExpiryDate);
if ((expiryGroups.ElementAt(1).ExpiryDate - expiryGroups.ElementAt(0).ExpiryDate).TotalDays > 30)
return true;
}
}
return false;
}

View File

@ -120,7 +120,7 @@ namespace XenAdmin.Dialogs.OptionsPages
log.Warn("Could not unprotect internet proxy password.", e);
}
ConnectionTimeoutNud.Value = Properties.Settings.Default.ConnectionTimeout / 1000;
ConnectionTimeoutNud.Value = (decimal) Properties.Settings.Default.ConnectionTimeout / 1000;
eventsDisabled = false;
}

View File

@ -230,7 +230,7 @@ namespace XenAdmin.SettingsPanels
Host host = (Host)_XenObject;
Host_metrics metrics = host.Connection.Resolve(host.metrics);
if (metrics != null)
nudMemoryUsage.Maximum = metrics.memory_total / (1024 * 1024);
nudMemoryUsage.Maximum = (decimal) metrics.memory_total / (1024 * 1024);
}
Repopulate();

View File

@ -67,7 +67,7 @@ namespace XenAdmin.Actions
{
if (startupOptions != null)
{
double increment = 10 / Math.Max(startupOptions.Count, 1);
double increment = 10.0 / Math.Max(startupOptions.Count, 1);
int i = 0;
// First set any VM restart priorities supplied
foreach (VM vm in startupOptions.Keys)