9002 references to Math
AnalyzeCiFailure (13)
AnalyzeCiFailure.Tests (1)
aspire (75)
Utils\ConsoleActivityLogger.cs (14)
465var durationWidth = Math.Max(10, orderedRecords.Max(r => FormatSummaryDuration(r.Duration, totalTimeline).Length));
466var nameWidth = Math.Max(timelineLabel.Length, orderedRecords.Max(r => StringUtils.RemoveMarkup(GetIndentedDisplayName(r)).Length));
495var padding = renderTimeline ? Math.Max(0, nameWidth - plainDisplayName.Length) : 0;
603var level = Math.Max(record.Level, 0);
619var position = (int)Math.Round((double)tick * (width - 1) / SummaryTimelineTicks);
635var labelWidth = Math.Max(width + 2, startText.Length + 1 + endText.Length);
636var spacing = Math.Max(1, labelWidth - startText.Length - endText.Length);
664var timelineWidth = Math.Max(
699var pointIndex = Math.Clamp((int)Math.Round((startPosition + endPosition) / 2, MidpointRounding.AwayFromZero), 0, width - 1);
704var startIndex = Math.Clamp((int)Math.Floor(startPosition), 0, width - 1);
705var endIndex = Math.Clamp((int)Math.Ceiling(endPosition), startIndex, width - 1);
Utils\EnvironmentChecker\ContainerRuntimeCheck.cs (4)
183new Version(version.Major, version.Minor, Math.Max(version.Build, 0), Math.Max(version.Revision, 0)) <=
184new Version(minimumVersion.Major, minimumVersion.Minor, Math.Max(minimumVersion.Build, 0), Math.Max(minimumVersion.Revision, 0));
aspire-managed (2)
aspire-tray (73)
src\Aspire.Tray\Common\TrayPanel.cs (11)
122value = Math.Max(HeaderHeight + FooterHeight + RowHeight, value);
398_scroll = Math.Clamp(before - deltaY, 0, Math.Max(0, _contentHeight - _viewport.Height));
511_scroll += Math.Min(bottom - _viewport.Bottom, Math.Max(0, top - _viewport.Y));
610: wrap ? (index + step + order.Count) % order.Count : Math.Clamp(index + step, 0, order.Count - 1);
829var height = Math.Min(_maxHeight, chrome + _contentHeight);
830_viewport = new(0, HeaderHeight + noticeHeight, Width, Math.Max(0, height - chrome));
831_scroll = Math.Clamp(_scroll, 0, Math.Max(0, _contentHeight - _viewport.Height));
912var thumb = Math.Max(24, _viewport.Height * _viewport.Height / _contentHeight);
src\Aspire.Tray\Common\TrayPanelGeometry.cs (24)
30var x = Math.Max(X, other.X);
31var y = Math.Max(Y, other.Y);
32var right = Math.Min(Right, other.Right);
33var bottom = Math.Min(Bottom, other.Bottom);
99var start = startDegrees * Math.PI / 180;
100var sweep = sweepDegrees * Math.PI / 180;
101var x0 = centerX + radius * Math.Cos(start);
102var y0 = centerY + radius * Math.Sin(start);
111var count = Math.Max(1, (int)Math.Ceiling(Math.Abs(sweep) / (Math.PI / 2) - 1e-9));
115var k = 4.0 / 3.0 * Math.Tan(step / 4) * radius;
120var (s0, c0) = Math.SinCos(a0);
121var (s1, c1) = Math.SinCos(a1);
143var limit = Math.Min(rect.Width, rect.Height) / 2;
144topLeft = Math.Clamp(topLeft, 0, limit);
145topRight = Math.Clamp(topRight, 0, limit);
146bottomRight = Math.Clamp(bottomRight, 0, limit);
147bottomLeft = Math.Clamp(bottomLeft, 0, limit);
209minX = Math.Min(minX, x);
210minY = Math.Min(minY, y);
211maxX = Math.Max(maxX, x);
212maxY = Math.Max(maxY, y);
src\Aspire.Tray\Common\TrayPanelPalette.cs (10)
27public static PanelColor FromRgba(byte r, byte g, byte b, double alpha) => new(r, g, b, (byte)Math.Round(Math.Clamp(alpha, 0, 1) * 255));
29public PanelColor WithAlpha(double alpha) => this with { A = (byte)Math.Round(Math.Clamp(alpha, 0, 1) * 255) };
36(byte)Math.Round(R * a + background.R * (1 - a)),
37(byte)Math.Round(G * a + background.G * (1 - a)),
38(byte)Math.Round(B * a + background.B * (1 - a)));
97var lighter = Math.Max(Luminance(first), Luminance(second));
98var darker = Math.Min(Luminance(first), Luminance(second));
106return c <= 0.03928 ? c / 12.92 : Math.Pow((c + 0.055) / 1.055, 2.4);
TrayApplication.Panel.cs (17)
182var margin = (int)Math.Round(PanelScreenMargin * scale);
183_panel!.MaxHeight = Math.Min(TrayPanel.DefaultMaxHeight, (work.Bottom - work.Top - 2 * margin) / scale);
184var width = (int)Math.Round(TrayPanel.Width * scale);
185var height = (int)Math.Round(_panel.Scene.Height * scale);
209x = Math.Clamp(x, work.Left + margin, Math.Max(work.Left + margin, work.Right - margin - width));
210y = Math.Clamp(y, work.Top + margin, Math.Max(work.Top + margin, work.Bottom - margin - height));
217var diameter = (int)Math.Round(2 * TrayPanel.CornerRadius * scale);
315if (_panelPaletteDirty || Math.Abs(rect.Bottom - rect.Top - Math.Round(_panel!.Scene.Height * PanelScale)) > 0.5)
686rect.Top = (int)Math.Round(text.Baseline * PanelScale) - metrics.Ascent;
793var height = -(int)Math.Round(PanelFonts.Size(role) * PanelScale);
828Left = (int)Math.Round(rect.X * scale),
829Top = (int)Math.Round(rect.Y * scale),
830Right = (int)Math.Round(rect.Right * scale),
831Bottom = (int)Math.Round(rect.Bottom * scale)
Aspire.Cli.EndToEnd.Tests (2)
Aspire.Cli.Tests (4)
Aspire.Dashboard (111)
Components\Controls\ApplicationSummary.razor.cs (6)
312? (await repository.GetLogSummariesAsync(CreateLogsContext(s_errorLogFilters, Math.Max(0, errorCount - RecentItemCount), RecentItemCount), cancellationToken).ConfigureAwait(false)).Items
319? (await repository.GetTraceSummariesAsync(CreateTracesRequest([s_failedTraceFilter], Math.Max(0, failedTraceCount - RecentItemCount), RecentItemCount), cancellationToken).ConfigureAwait(false)).PagedResult.Items
436var logCount = Math.Min(errorLogCount, MaxActivityErrorLogs);
466windowMinutes = Math.Max(s_activityBucketSize.TotalMinutes, (windowEnd - oldestSampled).TotalMinutes);
515var index = (int)Math.Ceiling(percentile * values.Count) - 1;
516return values[Math.Clamp(index, 0, values.Count - 1)];
Components\Controls\Chart\SparklinePath.cs (12)
83var top = v > 0 ? Math.Min(valueY, zeroY - MinBarHeight) : zeroY;
84var bottom = v > 0 ? zeroY : Math.Max(valueY, zeroY + MinBarHeight);
104min = min is null ? v : Math.Min(min.Value, v);
105max = max is null ? v : Math.Max(max.Value, v);
115scale = new Scale(Math.Min(0, min.Value), Math.Max(0, max.Value), height);
187tangents[i] = Math.Sign(s0) * Math.Min(Math.Min(Math.Abs(s0), Math.Abs(s1)), 0.5 * Math.Abs(p)) * 2;
Components\Pages\ResourceOverview.razor.cs (4)
318? (await repository.GetLogSummariesAsync(CreateLogsContext(key, attentionFilters, Math.Max(0, attentionCount - RecentItemCount), RecentItemCount), cancellationToken).ConfigureAwait(false)).Items
323? (await repository.GetLogSummariesAsync(CreateLogsContext(key, [], Math.Max(0, allLogs.TotalItemCount - RecentItemCount), RecentItemCount), cancellationToken).ConfigureAwait(false)).Items
331? (await repository.GetTraceSummariesAsync(CreateTracesRequest(key, [], Math.Max(0, traceCount - RecentItemCount), RecentItemCount), cancellationToken).ConfigureAwait(false)).PagedResult.Items
822var span = Math.Clamp(requested, 1, Columns);
Otlp\Storage\SqliteTelemetryRepository.Traces.Reads.cs (10)
29? Math.Max(aggregate.TotalItemCount - Math.Max(latestItemCount, 0), 0)
31query.Parameters.Add("StartIndex", (long)Math.Max(context.StartIndex, 0) + hiddenItemCount);
32query.Parameters.Add("Count", Math.Max(context.Count, 0));
64query.Parameters.Add("StartIndex", Math.Max(context.StartIndex, 0));
65query.Parameters.Add("Count", Math.Max(context.Count, 0));
66query.Parameters.Add("LatestItemCount", Math.Max(context.LatestItemCount ?? int.MaxValue, 0));
403query.Parameters.Add("StartIndex", Math.Max(context.StartIndex, 0));
404query.Parameters.Add("Count", Math.Max(context.Count, 0));
442query.Parameters.Add("RequestCount", Math.Max(request.MaxCount, 0));
Aspire.Dashboard.Components.Tests (1)
Aspire.Dashboard.Playwright.Tests (28)
Integration\Playwright\ResourcePaneMotionTests.cs (7)
93Assert.InRange(Math.Abs(frame[7] - frame[9]), 0, .5);
94Assert.InRange(Math.Abs(frame[6] - frame[10]), 0, .5);
95Assert.InRange(Math.Abs(frame[5] - (frame[9] - frame[8] - frame[0])), 0, .5);
217Assert.InRange(Math.Abs(frame[1] - expectedDetailsWidth), 0, .1);
235Assert.InRange(Math.Abs(frame[2] - frame[0]), 0, .1);
548var intermediate = frames.Any(frame => frame[0] > Math.Min(start.Width, end.Width) + 0.1 && frame[0] < Math.Max(start.Width, end.Width) - 0.1);
Integration\Playwright\ResourcePaneResponsiveTests.cs (11)
220Assert.All(metrics[5..7], value => Assert.InRange(Math.Abs(value), 0, .5));
462await page.SetViewportSizeAsync(width + (int)Math.Round(chrome), 1000);
985Assert.All(actual.Zip(expected), pair => Assert.True(Math.Abs(pair.First - pair.Second) <= 1,
1047await page.SetViewportSizeAsync(width + (int)Math.Round(chromeWidth), 1000);
1491Assert.True(Math.Abs(delta) <= 1, $"{selector}: delta={delta}; state={state}; dark={dark}");
2038Assert.True(Math.Abs(current[0] - rest[0]) < 0.5 && Math.Abs(current[1] - rest[1]) < 0.5,
2041Assert.True(Math.Abs(current[5] - current[0]) < 0.5 && Math.Abs(current[6] - current[2]) < 0.5,
2207Assert.True(Math.Abs(current[0] - rest[0]) < 0.5 && Math.Abs(current[1] - rest[1]) < 0.5,
Aspire.Deployment.EndToEnd.Tests (3)
Aspire.Hosting (24)
Aspire.Hosting.Azure (1)
Aspire.Hosting.Azure.ApiManagement (1)
Aspire.Hosting.Azure.AppContainers (1)
Aspire.Hosting.Azure.Kubernetes (1)
Aspire.Hosting.Azure.Sql (1)
Aspire.Hosting.Browsers (2)
Aspire.Hosting.Browsers.Tests (3)
Aspire.Hosting.CodeGeneration.Go (1)
Aspire.Hosting.CodeGeneration.Go.Tests (2)
Aspire.Hosting.CodeGeneration.Java (1)
Aspire.Hosting.CodeGeneration.Rust (1)
Aspire.Hosting.Docker (3)
Aspire.Hosting.Foundry (1)
Aspire.Hosting.Kubernetes (3)
Aspire.Hosting.Native.Client (1)
Aspire.Hosting.Native.CodeGeneration (1)
Aspire.Hosting.Native.Core.Tests (1)
Aspire.Hosting.Native.Server (7)
Aspire.Hosting.Radius (1)
Aspire.Hosting.RemoteHost (6)
Aspire.Hosting.RemoteHost.Tests (3)
Aspire.Hosting.Tests (5)
Aspire.Playground.Tests (1)
Aspire.TerminalHost (2)
Aspire.TestTools (2)
Aspire.Tray.Tests (99)
src\Aspire.Tray\Common\TrayPanel.cs (11)
122value = Math.Max(HeaderHeight + FooterHeight + RowHeight, value);
398_scroll = Math.Clamp(before - deltaY, 0, Math.Max(0, _contentHeight - _viewport.Height));
511_scroll += Math.Min(bottom - _viewport.Bottom, Math.Max(0, top - _viewport.Y));
610: wrap ? (index + step + order.Count) % order.Count : Math.Clamp(index + step, 0, order.Count - 1);
829var height = Math.Min(_maxHeight, chrome + _contentHeight);
830_viewport = new(0, HeaderHeight + noticeHeight, Width, Math.Max(0, height - chrome));
831_scroll = Math.Clamp(_scroll, 0, Math.Max(0, _contentHeight - _viewport.Height));
912var thumb = Math.Max(24, _viewport.Height * _viewport.Height / _contentHeight);
src\Aspire.Tray\Common\TrayPanelGeometry.cs (24)
30var x = Math.Max(X, other.X);
31var y = Math.Max(Y, other.Y);
32var right = Math.Min(Right, other.Right);
33var bottom = Math.Min(Bottom, other.Bottom);
99var start = startDegrees * Math.PI / 180;
100var sweep = sweepDegrees * Math.PI / 180;
101var x0 = centerX + radius * Math.Cos(start);
102var y0 = centerY + radius * Math.Sin(start);
111var count = Math.Max(1, (int)Math.Ceiling(Math.Abs(sweep) / (Math.PI / 2) - 1e-9));
115var k = 4.0 / 3.0 * Math.Tan(step / 4) * radius;
120var (s0, c0) = Math.SinCos(a0);
121var (s1, c1) = Math.SinCos(a1);
143var limit = Math.Min(rect.Width, rect.Height) / 2;
144topLeft = Math.Clamp(topLeft, 0, limit);
145topRight = Math.Clamp(topRight, 0, limit);
146bottomRight = Math.Clamp(bottomRight, 0, limit);
147bottomLeft = Math.Clamp(bottomLeft, 0, limit);
209minX = Math.Min(minX, x);
210minY = Math.Min(minY, y);
211maxX = Math.Max(maxX, x);
212maxY = Math.Max(maxY, y);
src\Aspire.Tray\Common\TrayPanelPalette.cs (10)
27public static PanelColor FromRgba(byte r, byte g, byte b, double alpha) => new(r, g, b, (byte)Math.Round(Math.Clamp(alpha, 0, 1) * 255));
29public PanelColor WithAlpha(double alpha) => this with { A = (byte)Math.Round(Math.Clamp(alpha, 0, 1) * 255) };
36(byte)Math.Round(R * a + background.R * (1 - a)),
37(byte)Math.Round(G * a + background.G * (1 - a)),
38(byte)Math.Round(B * a + background.B * (1 - a)));
97var lighter = Math.Max(Luminance(first), Luminance(second));
98var darker = Math.Min(Luminance(first), Luminance(second));
106return c <= 0.03928 ? c / 12.92 : Math.Pow((c + 0.055) / 1.055, 2.4);
src\Aspire.Tray\Linux\LinuxPanelAccessibility.cs (8)
82LinuxPanelNative.gtk_fixed_move(container, control.Widget, (int)Math.Round(bounds.X), (int)Math.Round(bounds.Y));
83LinuxPanelNative.gtk_widget_set_size_request(control.Widget, Math.Max(1, (int)Math.Ceiling(bounds.Width)),
84Math.Max(1, (int)Math.Ceiling(bounds.Height)));
104LinuxPanelNative.gtk_fixed_put(container, widget, (int)Math.Round(bounds.X), (int)Math.Round(bounds.Y));
src\Aspire.Tray\Linux\LinuxTrayIcons.cs (3)
50var radius = Math.Min(width, height) * 0.16;
56Gtk.cairo_arc(context, x, y, radius * 1.25, 0, Math.Tau);
61Gtk.cairo_arc(context, x, y, radius, 0, Math.Tau);
src\Aspire.Tray\Linux\LinuxTrayPanel.cs (13)
116_anchorX = (int)Math.Round(anchor.CenterX);
117_anchorY = (int)Math.Round(anchor.Bottom);
435_panel.MaxHeight = Math.Min(TrayPanel.DefaultMaxHeight, workarea.Height / _scale - 16);
471var right = Math.Max(left, workarea.Right - width - margin);
472var x = Math.Clamp(anchorX - width / 2, left, right);
473var y = anchorY >= workarea.Bottom ? workarea.Bottom - height - margin : Math.Max(workarea.Y + margin, anchorY + margin);
474y = Math.Clamp(y, workarea.Y + margin, Math.Max(workarea.Y + margin, workarea.Bottom - height - margin));
485var height = (int)Math.Ceiling(_panel.Scene.Height);
502(int)Math.Floor(x), (int)Math.Floor(y), out var translatedX, out var translatedY) != 0)
690LinuxPanelNative.pango_layout_set_width(layout, (int)Math.Round(text.Bounds.Width * 1024));
702: Math.Round(text.Baseline * scale) / scale - LinuxPanelNative.pango_layout_get_baseline(layout) / 1024d;
TrayPanelTests.cs (17)
875Assert.True(lines.Any(guide => guide.Kind == PanelGuideKind.Center && Math.Abs(guide.Position - capMiddle) < 0.01
876|| guide.Kind == PanelGuideKind.Baseline && Math.Abs(guide.Position - text.Baseline) < 0.01),
975=> Math.Abs(a.X - b.X) < 1e-9 && Math.Abs(a.Y - b.Y) < 1e-9 && Math.Abs(a.Right - b.Right) < 1e-9 && Math.Abs(a.Bottom - b.Bottom) < 1e-9;
1030Assert.Equal((int)Math.Ceiling(Math.Abs(sweep) / 90), cubics.Count);
1033Assert.Equal(5, Math.Sqrt(Math.Pow(cubic.X3 - 10, 2) + Math.Pow(cubic.Y3 - 20, 2)), 6);
1036Assert.Equal(5, Math.Sqrt(Math.Pow(mid.X - 10, 2) + Math.Pow(mid.Y - 20, 2)), 2);
1038var end = (start + sweep) * Math.PI / 180;
1039Assert.Equal(10 + 5 * Math.Cos(end), cubics[^1].X3, 6);
1040Assert.Equal(20 + 5 * Math.Sin(end), cubics[^1].Y3, 6);
cdac-build-tool (1)
crossgen2 (2)
dotnet-aot (13)
dotnet-svcutil-lib (84)
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlBaseReader.cs (5)
1167actual = Math.Min(count, value.Length);
1199return ReadBytes(Base64Encoding, 3, 4, buffer, offset, Math.Min(count, 512), false);
1363return ReadBytes(Base64Encoding, 3, 4, buffer, offset, Math.Min(count, 512), true);
1372int actual = Math.Min(_trailByteCount, byteCount);
1442int actual = Math.Min(_trailByteCount, byteCount);
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlBinaryReader.cs (15)
864int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0);
876int actual = Math.Max(maxLength - maxTextNodeLength, 0);
934int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0);
946int actual = Math.Max(maxLength - maxTextNodeLength, 0);
976int maxBytesPerRead = Math.Max(_maxBytesPerRead - nodeLength, 0);
1228int actual = Math.Min(count, _arrayCount);
1260int actual = Math.Min(count, _arrayCount);
1292int actual = Math.Min(count, _arrayCount);
1324int actual = Math.Min(count, _arrayCount);
1356int actual = Math.Min(count, _arrayCount);
1388int actual = Math.Min(count, _arrayCount);
1420int actual = Math.Min(count, _arrayCount);
1447int actual = Math.Min(count, _arrayCount);
1474int actual = Math.Min(count, _arrayCount);
1501int actual = Math.Min(count, _arrayCount);
dotnet-user-jwts (1)
GenerateDocumentationAndConfigFiles (81)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
HelixTestTasks (3)
ilc (2)
ILCompiler.Compiler (32)
ILCompiler.DependencyAnalysisFramework (1)
ILCompiler.MetadataTransform (5)
ILCompiler.ReadyToRun (44)
ILCompiler.RyuJit (11)
ILCompiler.TypeSystem (8)
illink (2)
ILLink.RoslynAnalyzer (2)
Infrastructure.Common (1)
Infrastructure.Tests (8)
Microsoft.Analyzers.Local.Tests (1)
Microsoft.Arcade.Common (2)
Microsoft.AspNetCore.Antiforgery (2)
Microsoft.AspNetCore.App.Analyzers (2)
Microsoft.AspNetCore.Authentication (2)
Microsoft.AspNetCore.Authentication.Cookies (2)
Microsoft.AspNetCore.Authentication.OpenIdConnect (1)
Microsoft.AspNetCore.Components (5)
Microsoft.AspNetCore.Components.AI (1)
Microsoft.AspNetCore.Components.Endpoints (4)
Microsoft.AspNetCore.Components.Forms (2)
Microsoft.AspNetCore.Components.QuickGrid (3)
Microsoft.AspNetCore.Components.Server (14)
Microsoft.AspNetCore.Components.Server.AutoPause (1)
Microsoft.AspNetCore.Components.Web (35)
Virtualization\Virtualize.cs (31)
316var desiredItemsBefore = Math.Max(0, clamped - OverscanCount);
319desiredItemsBefore = Math.Max(0, _itemCount - capacity);
384return Math.Max(0, requested);
572var lastItemIndex = Math.Min(_itemsBefore + _visibleItemCapacity, _itemCount);
574var placeholdersBeforeCount = Math.Min(_loadedItemsStartIndex, lastItemIndex);
627_lastRenderedPlaceholderCount = Math.Max(0, lastItemIndex - _itemsBefore - _lastRenderedItemCount);
639var itemsAfter = Math.Max(0, _itemCount - _visibleItemCapacity - _itemsBefore);
772var itemsBefore = Math.Max(0, _itemCount - itemsAfter - visibleItemCapacity);
813var maximumCapacity = Math.Min(GetMaximumItemCapacity(), _itemCount);
814var doubledCapacity = (long)Math.Max(1, _visibleItemCapacity) * 2;
815var desiredCapacity = (int)Math.Min(
816Math.Max((long)visibleItemCapacity, doubledCapacity),
820: Math.Max(0, _itemCount - _itemsBefore - _visibleItemCapacity);
821var addedItems = Math.Min(
822Math.Max(0, desiredCapacity - _visibleItemCapacity),
918itemsInSpacer = Math.Max(0, (int)Math.Floor(spacerSize / effectiveItemSize) - OverscanCount);
919visibleItemCapacity = (int)Math.Ceiling(containerSize / effectiveItemSize) + 2 * OverscanCount;
920unusedItemCapacity = Math.Max(0, visibleItemCapacity - maxItemCount);
930int val => Math.Min(val, MaxItemCount),
936return (int)Math.Min((long)maxItemCount + (long)OverscanCount * 2, int.MaxValue);
951return (int)Math.Min(
953(long)_visibleItemCapacity + Math.Max(1, OverscanCount));
965itemsBefore = Math.Max(0, _itemCount - visibleItemCapacity);
1216var adjustedItemsBefore = Math.Min(_itemsBefore + countDelta, Math.Max(0, newTotalCount - _visibleItemCapacity));
1235var adjustedItemsBefore = Math.Min(
1237Math.Max(0, result.TotalItemCount - _visibleItemCapacity));
1238var adjustedItemCount = Math.Min(
1332var tailItemsBefore = Math.Max(0, result.TotalItemCount - _visibleItemCapacity);
1335var tailItemCount = Math.Min(_visibleItemCapacity, result.TotalItemCount - tailItemsBefore);
Microsoft.AspNetCore.Components.WebAssembly (5)
Microsoft.AspNetCore.Components.WebView (5)
Microsoft.AspNetCore.Cryptography.KeyDerivation (1)
Microsoft.AspNetCore.DataProtection (6)
Microsoft.AspNetCore.DataProtection.Abstractions (2)
Microsoft.AspNetCore.DataProtection.Extensions (2)
Microsoft.AspNetCore.DataProtection.MicroBenchmarks (3)
Microsoft.AspNetCore.Diagnostics (1)
Microsoft.AspNetCore.Diagnostics.Middleware (3)
Microsoft.AspNetCore.Diagnostics.Middleware.Tests (2)
Microsoft.AspNetCore.Grpc.JsonTranscoding (2)
Microsoft.AspNetCore.Hosting (1)
Microsoft.AspNetCore.Http (3)
Microsoft.AspNetCore.Http.Abstractions (5)
Microsoft.AspNetCore.Http.Connections (2)
Microsoft.AspNetCore.Http.Connections.Common (1)
Microsoft.AspNetCore.Http.Extensions (5)
Microsoft.AspNetCore.Http.Results (2)
Microsoft.AspNetCore.HttpLogging (10)
Microsoft.AspNetCore.HttpOverrides (4)
Microsoft.AspNetCore.HttpsPolicy (1)
Microsoft.AspNetCore.InternalTesting (1)
Microsoft.AspNetCore.Mvc.Core (3)
Microsoft.AspNetCore.Mvc.TagHelpers (3)
Microsoft.AspNetCore.Mvc.ViewFeatures (5)
Microsoft.AspNetCore.OpenApi (1)
Microsoft.AspNetCore.OpenApi.SourceGenerators (3)
Microsoft.AspNetCore.OutputCaching (4)
Microsoft.AspNetCore.Razor.Utilities.Shared (4)
Microsoft.AspNetCore.ResponseCaching (1)
Microsoft.AspNetCore.Routing (12)
Microsoft.AspNetCore.Server.HttpSys (4)
Microsoft.AspNetCore.Server.IIS (8)
Microsoft.AspNetCore.Server.Kestrel.Core (39)
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (4)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (3)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (1)
Microsoft.AspNetCore.SignalR.Client.Core (2)
Microsoft.AspNetCore.SignalR.Common (1)
Microsoft.AspNetCore.SignalR.Core (2)
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (2)
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (1)
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
Microsoft.AspNetCore.StaticAssets (2)
Microsoft.AspNetCore.StaticFiles (1)
Microsoft.AspNetCore.TestHost (2)
Microsoft.AspNetCore.WebSockets (5)
Microsoft.AspNetCore.WebUtilities (29)
MultipartReaderStream.cs (9)
187var slice = buffer.AsSpan(offset, Math.Min(count, index));
207read = _innerStream.Read(buffer, offset, Math.Min(count, matchOffset - bufferedData.Offset));
218read = _innerStream.Read(buffer, offset, Math.Min(count, bufferedData.Count));
271var slice = buffer[..Math.Min(buffer.Length, index)];
294var slice = buffer[..Math.Min(buffer.Length, matchOffset - bufferedData.Offset)];
308read = _innerStream.Read(buffer.Span[..Math.Min(buffer.Length, bufferedData.Count)]);
343matchOffset = Math.Max(segment1.Offset, segment1.Offset + segment1.Count - matchBytes.Length);
370bufferSize = Math.Max(4096, bufferSize);
379bufferSize = Math.Max(4096, bufferSize);
Microsoft.Build (80)
Logging\BinaryLogger\Postprocessing\SubStream.cs (8)
49count = Math.Min((int)Math.Max(Length - _position, 0), count);
72count = Math.Min((int)Math.Max(Length - _position, 0), count);
87buffer = buffer.Slice(0, Math.Min((int)Math.Max(Length - _position, 0), buffer.Length));
95buffer = buffer.Slice(0, Math.Min((int)Math.Max(Length - _position, 0), buffer.Length));
src\msbuild\artifacts\.packages\microsoft.codeanalysis.collections\5.0.0-1.25277.114\contentFiles\cs\net9.0\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
Microsoft.Build.Framework (18)
Microsoft.Build.Tasks.Core (7)
Microsoft.Build.Tasks.Git (2)
Microsoft.CodeAnalysis (111)
CodeGen\LocalScopeManager.cs (12)
269begin = Math.Min(begin, bounds.Begin);
270end = Math.Max(end, bounds.End);
293begin = Math.Min(begin, bounds.Begin);
294end = Math.Max(end, bounds.End);
441begin = Math.Min(begin, block.Start);
442end = Math.Max(end, block.Start + block.TotalSize);
452begin = Math.Min(begin, nestedBounds.Begin);
453end = Math.Max(end, nestedBounds.End);
486begin = Math.Min(begin, block.Start);
487end = Math.Max(end, block.Start + block.TotalSize);
497begin = Math.Min(begin, nestedBounds.Begin);
498end = Math.Max(end, nestedBounds.End);
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
Text\SourceText.cs (10)
328bufferSize = Math.Min(maxBufferSize, length);
582int count = Math.Min(buffer.Length, end - offset);
660var charsToCopy = Math.Min(CharBufferSize, length - index);
747int position = Math.Max(Math.Min(span.Start, this.Length), 0);
748int length = Math.Min(span.End, this.Length) - position;
757int copyLength = Math.Min(tempBuffer.Length, length);
1083var limit = Math.Min(_lineStarts.Count, lastLineNumber + 4);
1122var contentLength = Math.Min(length - position, buffer.Length);
1271var count = Math.Min(this.Length - position, CharBufferSize);
Microsoft.CodeAnalysis.Analyzers (103)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
Microsoft.CodeAnalysis.AnalyzerUtilities (115)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
Microsoft.CodeAnalysis.CodeStyle (85)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
Microsoft.CodeAnalysis.CodeStyle.Fixes (3)
Microsoft.CodeAnalysis.CSharp (51)
Binder\PatternExplainer.cs (5)
63distanceInfo = (Math.Max(reachabilityInfo?.Contains(new NullableWalker.DecisionDagReachabilityInfo(e, whenTrue: true)) == false ? infinity : 0, distance(e.Next)), e.Next);
72var trueDist1 = Math.Max(reachabilityInfo?.Contains(new NullableWalker.DecisionDagReachabilityInfo(t, whenTrue: true)) == false ? infinity : 0, distance(t.WhenTrue));
73var falseDist1 = Math.Max(reachabilityInfo?.Contains(new NullableWalker.DecisionDagReachabilityInfo(t, whenTrue: false)) == false ? infinity : 0, distance(t.WhenFalse));
77var trueDist2 = Math.Max(reachabilityInfo?.Contains(new NullableWalker.DecisionDagReachabilityInfo(w, whenTrue: true)) == false ? infinity : 0, distance(w.WhenTrue));
78var falseDist2 = Math.Max(reachabilityInfo?.Contains(new NullableWalker.DecisionDagReachabilityInfo(w, whenTrue: false)) == false ? infinity : 0, distance(w.WhenFalse));
Microsoft.CodeAnalysis.CSharp.CodeStyle (7)
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (4)
Microsoft.CodeAnalysis.CSharp.Features (22)
Microsoft.CodeAnalysis.CSharp.Workspaces (7)
Microsoft.CodeAnalysis.Extensions.Package (20)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
Microsoft.CodeAnalysis.Features (37)
Microsoft.CodeAnalysis.NetAnalyzers (33)
Microsoft.CodeAnalysis.Razor.Compiler (12)
Microsoft.CodeAnalysis.Razor.DotNetFormat (16)
Microsoft.CodeAnalysis.ResxSourceGenerator (104)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
Microsoft.CodeAnalysis.Scripting (7)
Microsoft.CodeAnalysis.VisualBasic (48)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (12)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Formatting\Rules\ElasticTriviaFormattingRule.vb (6)
221Return CreateAdjustNewLinesOperation(Math.Max(If(operation Is Nothing, 1, operation.Line), 0), AdjustNewLinesOption.PreserveLines)
338Return Math.Max(lines, 0)
351Return Math.Max(If(lines > afterCommentWithBlank, lines, afterCommentWithBlank), 0)
355Return Math.Max(totalLines - blankLines + leadingBlankLines, 0)
358Return Math.Max(totalLines, 0)
361Return Math.Max(lines, 0)
Microsoft.CodeAnalysis.VisualBasic.CodeStyle.Fixes (2)
Microsoft.CodeAnalysis.VisualBasic.Features (8)
Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers (1)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (13)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Formatting\Rules\ElasticTriviaFormattingRule.vb (6)
221Return CreateAdjustNewLinesOperation(Math.Max(If(operation Is Nothing, 1, operation.Line), 0), AdjustNewLinesOption.PreserveLines)
338Return Math.Max(lines, 0)
351Return Math.Max(If(lines > afterCommentWithBlank, lines, afterCommentWithBlank), 0)
355Return Math.Max(totalLines - blankLines + leadingBlankLines, 0)
358Return Math.Max(totalLines, 0)
361Return Math.Max(lines, 0)
Microsoft.CodeAnalysis.Workspaces (117)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (2)
Microsoft.Data.Analysis (140)
PrimitiveDataFrameColumnComputations.cs (120)
255mutableSpan[i] = (byte)(Math.Abs((decimal)mutableSpan[i]));
286ret = (byte)(Math.Max(readOnlySpan[i], ret));
330ret = (byte)Math.Max(span[(int)row], ret);
350ret = (byte)(Math.Min(readOnlySpan[i], ret));
394ret = (byte)Math.Min(span[(int)row], ret);
542value = (byte)(Math.Max(readOnlySpan[i], value));
569value = (byte)(Math.Max(readOnlySpan[(int)row], value));
590value = (byte)(Math.Min(readOnlySpan[i], value));
617value = (byte)(Math.Min(readOnlySpan[(int)row], value));
724mutableSpan[i] = (byte)(Math.Round((decimal)mutableSpan[i]));
742mutableSpan[i] = (char)(Math.Abs((decimal)mutableSpan[i]));
773ret = (char)(Math.Max(readOnlySpan[i], ret));
817ret = (char)Math.Max(span[(int)row], ret);
837ret = (char)(Math.Min(readOnlySpan[i], ret));
881ret = (char)Math.Min(span[(int)row], ret);
1029value = (char)(Math.Max(readOnlySpan[i], value));
1056value = (char)(Math.Max(readOnlySpan[(int)row], value));
1077value = (char)(Math.Min(readOnlySpan[i], value));
1104value = (char)(Math.Min(readOnlySpan[(int)row], value));
1211mutableSpan[i] = (char)(Math.Round((decimal)mutableSpan[i]));
1229mutableSpan[i] = (decimal)(Math.Abs((decimal)mutableSpan[i]));
1260ret = (decimal)(Math.Max(readOnlySpan[i], ret));
1304ret = (decimal)Math.Max(span[(int)row], ret);
1324ret = (decimal)(Math.Min(readOnlySpan[i], ret));
1368ret = (decimal)Math.Min(span[(int)row], ret);
1516value = (decimal)(Math.Max(readOnlySpan[i], value));
1543value = (decimal)(Math.Max(readOnlySpan[(int)row], value));
1564value = (decimal)(Math.Min(readOnlySpan[i], value));
1591value = (decimal)(Math.Min(readOnlySpan[(int)row], value));
1698mutableSpan[i] = (decimal)(Math.Round((decimal)mutableSpan[i]));
1716mutableSpan[i] = (double)(Math.Abs((decimal)mutableSpan[i]));
1747ret = (double)(Math.Max(readOnlySpan[i], ret));
1791ret = (double)Math.Max(span[(int)row], ret);
1811ret = (double)(Math.Min(readOnlySpan[i], ret));
1855ret = (double)Math.Min(span[(int)row], ret);
2003value = (double)(Math.Max(readOnlySpan[i], value));
2030value = (double)(Math.Max(readOnlySpan[(int)row], value));
2051value = (double)(Math.Min(readOnlySpan[i], value));
2078value = (double)(Math.Min(readOnlySpan[(int)row], value));
2185mutableSpan[i] = (double)(Math.Round((decimal)mutableSpan[i]));
2203mutableSpan[i] = (float)(Math.Abs((decimal)mutableSpan[i]));
2234ret = (float)(Math.Max(readOnlySpan[i], ret));
2278ret = (float)Math.Max(span[(int)row], ret);
2298ret = (float)(Math.Min(readOnlySpan[i], ret));
2342ret = (float)Math.Min(span[(int)row], ret);
2490value = (float)(Math.Max(readOnlySpan[i], value));
2517value = (float)(Math.Max(readOnlySpan[(int)row], value));
2538value = (float)(Math.Min(readOnlySpan[i], value));
2565value = (float)(Math.Min(readOnlySpan[(int)row], value));
2672mutableSpan[i] = (float)(Math.Round((decimal)mutableSpan[i]));
2690mutableSpan[i] = (int)(Math.Abs((decimal)mutableSpan[i]));
2721ret = (int)(Math.Max(readOnlySpan[i], ret));
2765ret = (int)Math.Max(span[(int)row], ret);
2785ret = (int)(Math.Min(readOnlySpan[i], ret));
2829ret = (int)Math.Min(span[(int)row], ret);
2977value = (int)(Math.Max(readOnlySpan[i], value));
3004value = (int)(Math.Max(readOnlySpan[(int)row], value));
3025value = (int)(Math.Min(readOnlySpan[i], value));
3052value = (int)(Math.Min(readOnlySpan[(int)row], value));
3159mutableSpan[i] = (int)(Math.Round((decimal)mutableSpan[i]));
3177mutableSpan[i] = (long)(Math.Abs((decimal)mutableSpan[i]));
3208ret = (long)(Math.Max(readOnlySpan[i], ret));
3252ret = (long)Math.Max(span[(int)row], ret);
3272ret = (long)(Math.Min(readOnlySpan[i], ret));
3316ret = (long)Math.Min(span[(int)row], ret);
3464value = (long)(Math.Max(readOnlySpan[i], value));
3491value = (long)(Math.Max(readOnlySpan[(int)row], value));
3512value = (long)(Math.Min(readOnlySpan[i], value));
3539value = (long)(Math.Min(readOnlySpan[(int)row], value));
3646mutableSpan[i] = (long)(Math.Round((decimal)mutableSpan[i]));
3664mutableSpan[i] = (sbyte)(Math.Abs((decimal)mutableSpan[i]));
3695ret = (sbyte)(Math.Max(readOnlySpan[i], ret));
3739ret = (sbyte)Math.Max(span[(int)row], ret);
3759ret = (sbyte)(Math.Min(readOnlySpan[i], ret));
3803ret = (sbyte)Math.Min(span[(int)row], ret);
3951value = (sbyte)(Math.Max(readOnlySpan[i], value));
3978value = (sbyte)(Math.Max(readOnlySpan[(int)row], value));
3999value = (sbyte)(Math.Min(readOnlySpan[i], value));
4026value = (sbyte)(Math.Min(readOnlySpan[(int)row], value));
4133mutableSpan[i] = (sbyte)(Math.Round((decimal)mutableSpan[i]));
4151mutableSpan[i] = (short)(Math.Abs((decimal)mutableSpan[i]));
4182ret = (short)(Math.Max(readOnlySpan[i], ret));
4226ret = (short)Math.Max(span[(int)row], ret);
4246ret = (short)(Math.Min(readOnlySpan[i], ret));
4290ret = (short)Math.Min(span[(int)row], ret);
4438value = (short)(Math.Max(readOnlySpan[i], value));
4465value = (short)(Math.Max(readOnlySpan[(int)row], value));
4486value = (short)(Math.Min(readOnlySpan[i], value));
4513value = (short)(Math.Min(readOnlySpan[(int)row], value));
4620mutableSpan[i] = (short)(Math.Round((decimal)mutableSpan[i]));
4638mutableSpan[i] = (uint)(Math.Abs((decimal)mutableSpan[i]));
4669ret = (uint)(Math.Max(readOnlySpan[i], ret));
4713ret = (uint)Math.Max(span[(int)row], ret);
4733ret = (uint)(Math.Min(readOnlySpan[i], ret));
4777ret = (uint)Math.Min(span[(int)row], ret);
4925value = (uint)(Math.Max(readOnlySpan[i], value));
4952value = (uint)(Math.Max(readOnlySpan[(int)row], value));
4973value = (uint)(Math.Min(readOnlySpan[i], value));
5000value = (uint)(Math.Min(readOnlySpan[(int)row], value));
5107mutableSpan[i] = (uint)(Math.Round((decimal)mutableSpan[i]));
5125mutableSpan[i] = (ulong)(Math.Abs((decimal)mutableSpan[i]));
5156ret = (ulong)(Math.Max(readOnlySpan[i], ret));
5200ret = (ulong)Math.Max(span[(int)row], ret);
5220ret = (ulong)(Math.Min(readOnlySpan[i], ret));
5264ret = (ulong)Math.Min(span[(int)row], ret);
5412value = (ulong)(Math.Max(readOnlySpan[i], value));
5439value = (ulong)(Math.Max(readOnlySpan[(int)row], value));
5460value = (ulong)(Math.Min(readOnlySpan[i], value));
5487value = (ulong)(Math.Min(readOnlySpan[(int)row], value));
5594mutableSpan[i] = (ulong)(Math.Round((decimal)mutableSpan[i]));
5612mutableSpan[i] = (ushort)(Math.Abs((decimal)mutableSpan[i]));
5643ret = (ushort)(Math.Max(readOnlySpan[i], ret));
5687ret = (ushort)Math.Max(span[(int)row], ret);
5707ret = (ushort)(Math.Min(readOnlySpan[i], ret));
5751ret = (ushort)Math.Min(span[(int)row], ret);
5899value = (ushort)(Math.Max(readOnlySpan[i], value));
5926value = (ushort)(Math.Max(readOnlySpan[(int)row], value));
5947value = (ushort)(Math.Min(readOnlySpan[i], value));
5974value = (ushort)(Math.Min(readOnlySpan[(int)row], value));
6081mutableSpan[i] = (ushort)(Math.Round((decimal)mutableSpan[i]));
Microsoft.Deployment.DotNet.Releases (1)
Microsoft.Diagnostics.DataContractReader.Contracts (8)
Microsoft.Diagnostics.DataContractReader.Legacy (31)
SOSDacImpl.cs (14)
4132count = Math.Min(count, (uint)refs.Length);
4160_index = Math.Min(_index + count, (uint)_refs.Length);
5291for (int i = 0; i < Math.Min(GCConstants.DAC_NUM_GC_DATA_POINTS, heapData.InterestingData.Count); i++)
5295for (int i = 0; i < Math.Min(GCConstants.DAC_MAX_COMPACT_REASONS_COUNT, heapData.CompactReasons.Count); i++)
5299for (int i = 0; i < Math.Min(GCConstants.DAC_MAX_EXPAND_MECHANISMS_COUNT, heapData.ExpandMechanisms.Count); i++)
5303for (int i = 0; i < Math.Min(GCConstants.DAC_MAX_GC_MECHANISM_BITS_COUNT, heapData.InterestingMechanismBits.Count); i++)
5364for (int i = 0; i < Math.Min(GCConstants.DAC_MAX_GLOBAL_GC_MECHANISMS_COUNT, globalMechanismsData.Count); i++)
6731int fillCount = Math.Min(count, loaderHeapCount);
7349count = Math.Min(count, (uint)values.Length);
7368_index = Math.Min(_index + count, (uint)_threads.Length);
7415count = Math.Min(count, (uint)values.Length);
7456uint toFetch = Math.Min(argCount, (uint)msg.Args.Count);
7457toFetch = Math.Min(toFetch, (uint)args.Length);
7469_index = Math.Min(_index + count, (uint)_messages.Length);
Microsoft.DiaSymReader (9)
Microsoft.DotNet.ApiCompatibility (1)
Microsoft.DotNet.Arcade.Sdk (1)
Microsoft.DotNet.Build.Tasks.Installers (1)
Microsoft.DotNet.Cli.InternalMicrosoft (1)
Microsoft.DotNet.Cli.Utils (3)
Microsoft.DotNet.HotReload.Watch (1)
Microsoft.DotNet.ILAssembler (16)
Microsoft.DotNet.XliffTasks (1)
Microsoft.Extensions.AI (1)
Microsoft.Extensions.AI.Abstractions (2)
Microsoft.Extensions.AI.Evaluation.NLP (13)
Microsoft.Extensions.AI.Evaluation.Reporting.Tests (1)
Microsoft.Extensions.AI.OpenAI.Tests (1)
Microsoft.Extensions.Caching.Hybrid (5)
Microsoft.Extensions.Caching.Memory (1)
Microsoft.Extensions.Caching.StackExchangeRedis (1)
Microsoft.Extensions.Configuration.Binder.SourceGeneration (3)
Microsoft.Extensions.Configuration.EnvironmentVariables (2)
Microsoft.Extensions.DataIngestion (3)
Microsoft.Extensions.DataIngestion.Markdig (1)
Microsoft.Extensions.DataIngestion.MarkItDown (1)
Microsoft.Extensions.DependencyInjection (3)
Microsoft.Extensions.DependencyModel (1)
Microsoft.Extensions.Diagnostics.ResourceMonitoring (20)
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (14)
Linux\AcceptanceTest.cs (9)
189Assert.Equal(0.1, Math.Round(provider.Resources.GuaranteedCpuUnits, 1)); // hack to make hardcoded calculation in resource utilization main package work.
190Assert.Equal(0.2d, Math.Round(provider.Resources.MaximumCpuUnits, 1)); // read from cpuset.cpus
392var roundedCpuUsedPercentage = Math.Round(utilization.CpuUsedPercentage, 1);
398Assert.Equal(roundedCpuUsedPercentage, Math.Round(cpuRequestFromGauge * 100));
400Assert.Equal(roundedCpuUsedPercentage, Math.Round(cpuFromGauge * 100));
477Assert.Equal(42, Math.Round(cpuLimitFromGauge * 100));
478Assert.Equal(84, Math.Round(cpuRequestFromGauge * 100));
479Assert.Equal(168, Math.Round(cpuUserTime * 100));
480Assert.Equal(81, Math.Round(cpuKernelTime * 100));
Microsoft.Extensions.DotNetDeltaApplier (1)
Microsoft.Extensions.Http.Diagnostics (2)
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Microsoft.Extensions.Http.Resilience (2)
Microsoft.Extensions.Http.Resilience.Tests (1)
Microsoft.Extensions.Identity.Core (1)
Microsoft.Extensions.Logging.Abstractions (2)
Microsoft.Extensions.Logging.Console (4)
Microsoft.Extensions.Logging.Generators (4)
Microsoft.Extensions.ServiceDiscovery.Dns (3)
Microsoft.Extensions.ServiceDiscovery.Dns.Tests.Fuzzing (1)
Microsoft.Extensions.Telemetry (5)
Microsoft.Extensions.VectorData.ConformanceTests (2)
Microsoft.Gen.Logging (1)
Microsoft.Interop.ComInterfaceGenerator (1)
Microsoft.Interop.SourceGeneration (4)
Microsoft.JSInterop (2)
Microsoft.Maui (60)
Layouts\LayoutExtensions.cs (10)
46 consumedWidth = Math.Min(bounds.Width, view.MaximumWidth);
50 var frameWidth = Math.Max(0, consumedWidth - margin.HorizontalThickness);
60 consumedHeight = Math.Min(bounds.Height, view.MaximumHeight);
64 var frameHeight = Math.Max(0, consumedHeight - margin.VerticalThickness);
84 desiredWidth = IsExplicitSet(view.Width) ? desiredWidth : Math.Min(bounds.Width, view.MaximumWidth);
121 desiredHeight = IsExplicitSet(view.Height) ? desiredHeight : Math.Min(bounds.Height, view.MaximumHeight);
189 size.Width = Math.Max(bounds.Width, size.Width);
194 size.Height = Math.Max(bounds.Height, size.Height);
225 bounds.Width = Math.Max(bounds.Width, presentedContent.DesiredSize.Width + padding.HorizontalThickness);
226 bounds.Height = Math.Max(bounds.Height, presentedContent.DesiredSize.Height + padding.VerticalThickness);
Microsoft.Maui.Controls (165)
LegacyLayouts\GridCalc.cs (33)
201 actualHeight = Math.Max(actualHeight, sizeRequest.Request.Height - assignedHeight - grid.RowSpacing * (GetRowSpan(child) - 1));
202 minimumHeight = Math.Max(minimumHeight, sizeRequest.Minimum.Height - assignedHeight - grid.RowSpacing * (GetRowSpan(child) - 1));
234 actualWidth = Math.Max(actualWidth, sizeRequest.Request.Width - assignedWidth - (GetColumnSpan(child) - 1) * grid.ColumnSpacing);
235 minimumWidth = Math.Max(minimumWidth, sizeRequest.Minimum.Width - assignedWidth - (GetColumnSpan(child) - 1) * grid.ColumnSpacing);
272 columnwWidthSum += Math.Max(0, c.ActualWidth);
284 rowHeightSum += Math.Max(0, r.ActualHeight);
317 double contractionNeeded = Math.Min(contractionSpace, Math.Max(currentSize.Width - targetWidth, 0));
325 double availableSpace = col.ActualWidth - Math.Max(col.MinimumWidth, 0);
352 double contractionNeeded = Math.Min(contractionSpace, Math.Max(currentSize.Height - targetHeight, 0));
394 starColumnWidth = Math.Min(column.ActualWidth, starColumnWidth);
411 double contractionNeeded = Math.Min(contractionSpace, Math.Max(request.Width - targetWidth, 0));
457 starRowHeight = Math.Min(row.ActualHeight, starRowHeight);
473 double contractionNeeded = Math.Min(contractionSpace, Math.Max(request.Height - targetHeight, 0));
500 lastRow = Math.Max(lastRow, GetRow(w) + GetRowSpan(w) - 1);
502 lastRow = Math.Max(lastRow, grid.RowDefinitions.Count - 1);
508 lastCol = Math.Max(lastCol, GetColumn(w) + GetColumnSpan(w) - 1);
510 lastCol = Math.Max(lastCol, grid.ColumnDefinitions.Count - 1);
605 starColWidth = Math.Max(starColWidth, GetUnassignedWidth(width, columnSpacing) / totalStarsWidth);
635 starRowHeight = Math.Max(starRowHeight, GetUnassignedHeight(height, rowSpacing) / totalStarsHeight);
677 actualWidth = Math.Max(actualWidth, sizeRequest.Request.Width - assignedWidth - columnSpacing);
678 minimumWidth = Math.Max(minimumWidth, sizeRequest.Minimum.Width - assignedWidth - columnSpacing);
697 starColRequestWidth = Math.Max(starColRequestWidth, col.ActualWidth / col.Width.Value);
698 starColMinWidth = Math.Max(starColMinWidth, col.MinimumWidth / col.Width.Value);
706 return Math.Max(widthConstraint / totalStarsWidth, starColMinWidth);
738 actualHeight = Math.Max(actualHeight, sizeRequest.Request.Height - assignedHeight - rowSpacing);
739 minimumHeight = Math.Max(minimumHeight, sizeRequest.Minimum.Height - assignedHeight - rowSpacing);
758 starRowRequestHeight = Math.Max(starRowRequestHeight, row.ActualHeight / row.Height.Value);
759 starRowMinHeight = Math.Max(starRowMinHeight, row.MinimumHeight / row.Height.Value);
767 return Math.Max(heightConstraint / totalStarsHeight, starRowMinHeight);
Shapes\Matrix.cs (24)
95 this *= CreateRotationRadians(angle * (Math.PI / 180.0));
102 this = CreateRotationRadians(angle * (Math.PI / 180.0)) * this;
109 this *= CreateRotationRadians(angle * (Math.PI / 180.0), centerX, centerY);
116 this = CreateRotationRadians(angle * (Math.PI / 180.0), centerX, centerY) * this;
148 this *= CreateSkewRadians(skewX * (Math.PI / 180.0),
149 skewY * (Math.PI / 180.0));
157 this = CreateSkewRadians(skewX * (Math.PI / 180.0),
158 skewY * (Math.PI / 180.0)) * this;
560 double sin = Math.Sin(angle);
561 double cos = Math.Cos(angle);
599 matrix.SetMatrix(1.0, Math.Tan(skewY),
600 Math.Tan(skewX), 1.0,
744 rect.X = Math.Min(Math.Min(point0.X, point1.X), Math.Min(point2.X, point3.X));
745 rect.Y = Math.Min(Math.Min(point0.Y, point1.Y), Math.Min(point2.Y, point3.Y));
747 rect.Width = Math.Max(Math.Max(point0.X, point1.X), Math.Max(point2.X, point3.X)) - rect.X;
748 rect.Height = Math.Max(Math.Max(point0.Y, point1.Y), Math.Max(point2.Y, point3.Y)) - rect.Y;
Microsoft.Maui.Controls.BindingSourceGen (1)
Microsoft.Maui.Essentials (12)
Microsoft.Maui.Graphics (98)
Rect.cs (12)
107 return FromLTRB(Math.Min(r1.Left, r2.Left), Math.Min(r1.Top, r2.Top), Math.Max(r1.Right, r2.Right), Math.Max(r1.Bottom, r2.Bottom));
117 double x = Math.Max(r1.X, r2.X);
118 double y = Math.Max(r1.Y, r2.Y);
119 double width = Math.Min(r1.Right, r2.Right) - x;
120 double height = Math.Min(r1.Bottom, r2.Bottom) - y;
209 return new Rect(Math.Round(X), Math.Round(Y), Math.Round(Width), Math.Round(Height));
RectF.cs (8)
108 return FromLTRB(Math.Min(r1.Left, r2.Left), Math.Min(r1.Top, r2.Top), Math.Max(r1.Right, r2.Right), Math.Max(r1.Bottom, r2.Bottom));
118 float x = Math.Max(r1.X, r2.X);
119 float y = Math.Max(r1.Y, r2.Y);
120 float width = Math.Min(r1.Right, r2.Right) - x;
121 float height = Math.Min(r1.Bottom, r2.Bottom) - y;
Text\AttributedTextRunExtensions.cs (10)
82 var length1 = Math.Min(first.Length, second.Length);
84 var length2 = Math.Max(first.Length, second.Length) - length1;
92 var length1 = Math.Min(first.Length, second.Length);
94 var length2 = Math.Max(first.Length, second.Length) - length1;
107 var length2 = Math.Max(first.Length, second.Length) - length1;
117 var length2 = Math.Max(first.Length, second.Length) - length1;
132 var length3 = Math.Max(first.Length, second.Length) - (length1 + length2);
145 var length3 = Math.Max(first.Length, second.Length) - (length1 + length2);
166 var start = Math.Max(run.Start, 0);
168 var length = Math.Min(run.Length, maxLength);
Microsoft.Maui.Graphics.Skia (9)
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (10)
Microsoft.Maui.Maps (40)
Primitives\MapSpan.cs (18)
8 const double EarthCircumferenceKm = GeographyUtils.EarthRadiusKm * 2 * Math.PI;
14 LatitudeDegrees = Math.Min(Math.Max(latitudeDegrees, MinimumRangeDegrees), 90.0);
15 LongitudeDegrees = Math.Min(Math.Max(longitudeDegrees, MinimumRangeDegrees), 180.0);
30 return new Distance(1000 * Math.Min(latKm, longKm) / 2);
36 north = Math.Min(Math.Max(north, 0), 90);
37 south = Math.Max(Math.Min(south, 0), -90);
38 double lat = Math.Max(Math.Min(Center.Latitude, north), south);
39 double maxDLat = Math.Min(north - lat, -south + lat) * 2;
40 return new MapSpan(new Location(lat, Center.Longitude), Math.Min(LatitudeDegrees, maxDLat), LongitudeDegrees);
80 double maxDLat = Math.Min(90 - Center.Latitude, 90 + Center.Latitude) * 2;
81 return new MapSpan(Center, Math.Min(LatitudeDegrees / zoomFactor, maxDLat), LongitudeDegrees / zoomFactor);
102 return EarthCircumferenceKm * Math.Cos(location.Latitude * Math.PI / 180.0);
Microsoft.Maui.Resizetizer (4)
Microsoft.ML.AutoML (68)
Sweepers\Parameters.cs (22)
229? Math.Pow(1.0 * _args.Max / _args.Min, 1.0 / (_args.NumSteps - 1))
231var logMax = Math.Log(_args.Max, logBase);
232var logMin = Math.Log(_args.Min, logBase);
233val = (long)(_args.Min * Math.Pow(logBase, normalizedValue * (logMax - logMin)));
258var logBase = _args.StepSize ?? Math.Pow(1.0 * _args.Max / _args.Min, 1.0 / (_args.NumSteps - 1));
261var maxPlusEpsilon = _args.Max * Math.Sqrt(logBase);
313float logBase = (float)(_args.StepSize ?? Math.Pow(1.0 * _args.Max / _args.Min, 1.0 / (_args.NumSteps - 1)));
314return (float)((Math.Log(valueTyped.Value, logBase) - Math.Log(_args.Min, logBase)) / (Math.Log(_args.Max, logBase) - Math.Log(_args.Min, logBase)));
355? Math.Pow(1.0 * _args.Max / _args.Min, 1.0 / (_args.NumSteps - 1))
357var logMax = Math.Log(_args.Max, logBase);
358var logMin = Math.Log(_args.Min, logBase);
359val = (float)(_args.Min * Math.Pow(logBase, normalizedValue * (logMax - logMin)));
376var logBase = _args.StepSize ?? Math.Pow(1.0 * _args.Max / _args.Min, 1.0 / (_args.NumSteps - 1));
379var maxPlusEpsilon = _args.Max * Math.Sqrt(logBase);
431float logBase = (float)(_args.StepSize ?? Math.Pow(1.0 * _args.Max / _args.Min, 1.0 / (_args.NumSteps - 1)));
432return (float)((Math.Log(valueTyped.Value, logBase) - Math.Log(_args.Min, logBase)) / (Math.Log(_args.Max, logBase) - Math.Log(_args.Min, logBase)));
Microsoft.ML.AutoML.Tests (13)
Microsoft.ML.Core (120)
Utilities\MathUtils.cs (46)
32return Math.Sqrt(x).ToFloat();
37return Math.Log(x).ToFloat();
42return Math.Log(a, newBase).ToFloat();
47return Math.Pow(x, y).ToFloat();
115result = Math.Max(result, x);
129result = Math.Min(result, x);
230intermediate += Math.Exp(inputs[i] - max);
234return (float)(max + Math.Log(1.0 + intermediate));
261return (float)(max + Math.Log(1.0 + Math.Exp(negDiff)));
288float absDiff = Math.Abs(a - b);
291float maxAbs = Math.Max(Math.Abs(a), Math.Abs(b));
296private static readonly double _constantForLogGamma = 0.5 * Math.Log(2 * Math.PI);
312int toAdd = (int)Math.Floor(7 - x);
316res = -Math.Log(v2);
321res += _constantForLogGamma + (x + 0.5) * Math.Log(x) - x;
364_logFactorialCache.Add(_logFactorialCache[i - 1] + Math.Log(i));
390return Math.Max(0, Math.Min(result, 1));
421if (Math.Abs(ratio - 1.0) < tol)
431return Math.Exp(LogGamma(a) + LogGamma(b) - LogGamma(a + b));
468return Math.Pow(x, a) * Math.Pow(1 - x, b) / (a * Beta(a, b)) * Lentz(adel, bdel);
524return Math.Tanh(x).ToFloat();
532return Math.Exp(x).ToFloat();
688maxOut = Math.Max(maxOut, src[i]);
753Double similarity = ab / (Math.Sqrt(a2 * b2) + epsilon);
755if (Math.Abs(similarity) > 1)
772? -prob * Math.Log(prob) - (1 - prob) * Math.Log(1 - prob)
773: -prob * Math.Log(prob, 2) - (1 - prob) * Math.Log(1 - prob, 2);
787? -probTrue * Math.Log(probPredicted) - (1 - probTrue) * Math.Log(1 - probPredicted)
788: -probTrue * Math.Log(probPredicted, 2) - (1 - probTrue) * Math.Log(1 - probPredicted, 2);
810soFar += Math.Exp(term - max);
813soFar = Math.Exp(max - term) * soFar + 1;
817return (float)Math.Log(soFar) + max;
826var res = Math.Sin(a);
827return Math.Abs(res) > 1 ? double.NaN : res;
836var res = Math.Cos(a);
837return Math.Abs(res) > 1 ? double.NaN : res;
Microsoft.ML.Core.Tests (19)
UnitTests\TestLoss.cs (7)
49float almostOutput = Math.Max((float)output * (1 + _epsilon), (float)output + _epsilon);
76TestHelper(loss, 1, 3, Math.Exp(-3), Math.Exp(-3));
77TestHelper(loss, 0, 3, Math.Exp(3), -Math.Exp(3));
78TestHelper(loss, 0, -3, Math.Exp(-3), -Math.Exp(-3));
Microsoft.ML.CpuMath (31)
Microsoft.ML.CpuMath.PerformanceTests (1)
Microsoft.ML.CpuMath.UnitTests (8)
Microsoft.ML.Data (154)
Data\BufferBuilder.cs (8)
181Array.Resize(ref _values, Math.Max(Math.Min(_length, checked(_count * 2)), 8));
183Array.Resize(ref _indices, Math.Max(Math.Min(_length, checked(_count * 2)), 8));
209Array.Resize(ref _values, Math.Max(Math.Min(_length, checked(_count * 2)), 8));
211Array.Resize(ref _indices, Math.Max(Math.Min(_length, checked(_count * 2)), 8));
Transforms\NormalizeColumnDbl.cs (21)
442get { return _m2.Select((m2, i) => Math.Sqrt(m2 / _cnz[i])).ToArray(); }
447get { return _m2.Select((m2, i) => Math.Sqrt(m2 / Math.Max(0, _cnz[i] - 1))).ToArray(); }
457get { return _m2.Select((m2, i) => m2 / Math.Max(0, _cnz[i] - 1)).ToArray(); }
511var val = _useLog ? (TFloat)Math.Log(origVal) : origVal;
732int cv = Math.Max(1, typeSrc.Size);
1006var val = UseLog ? (TFloat)Math.Log(input) : input;
1058int cv = Math.Max(1, typeSrc.Size);
1117var val = useLog ? (TFloat)Math.Log(values[i]) : values[i];
1133var val = useLog ? (TFloat)Math.Log(values[ii]) : values[ii];
1167_den = Math.Max(1, _binUpperBounds.Length - 1);
1242_den[i] = Math.Max(1, _binUpperBounds[i].Length - 1);
1261int cv = Math.Max(1, typeSrc.Size);
1436scale = 1 / Math.Max(Math.Abs(max), Math.Abs(min));
1472scale = 1 / (TFloat)Math.Sqrt(meanSquaredError + mean * mean);
1489return (TFloat)(0.5 + 0.5 * Math.Sign(x) * Math.Sqrt(1 - Math.Exp(-x2 * (4 / Math.PI + ax2) / (1 + ax2))));
Transforms\NormalizeColumnSng.cs (21)
443get { return _m2.Select((m2, i) => Math.Sqrt(m2 / _cnz[i])).ToArray(); }
448get { return _m2.Select((m2, i) => Math.Sqrt(m2 / Math.Max(0, _cnz[i] - 1))).ToArray(); }
458get { return _m2.Select((m2, i) => m2 / Math.Max(0, _cnz[i] - 1)).ToArray(); }
513var val = _useLog ? (TFloat)Math.Log(origVal) : origVal;
889int cv = Math.Max(1, typeSrc.Size);
1166var val = UseLog ? (TFloat)Math.Log(input) : input;
1218int cv = Math.Max(1, typeSrc.Size);
1278var val = useLog ? (TFloat)Math.Log(values[i]) : values[i];
1294var val = useLog ? (TFloat)Math.Log(values[ii]) : values[ii];
1328_den = Math.Max(1, _binUpperBounds.Length - 1);
1403_den[i] = Math.Max(1, _binUpperBounds[i].Length - 1);
1422int cv = Math.Max(1, typeSrc.Size);
1599scale = 1 / Math.Max(Math.Abs(max), Math.Abs(min));
1635scale = 1 / (TFloat)Math.Sqrt(meanSquaredError + mean * mean);
1652return (TFloat)(0.5 + 0.5 * Math.Sign(x) * Math.Sqrt(1 - Math.Exp(-x2 * (4 / Math.PI + ax2) / (1 + ax2))));
Utils\LossFunctions.cs (20)
147return 1 / Math.Max(1, (float)0.25 + scaledFeaturesNormSquared);
161return maxNumThreads >= 2 && Math.Abs(fullUpdate) > Threshold ? fullUpdate / maxNumThreads : fullUpdate;
179return Math.Log(Math.Max(x, 1e-8));
261var fullUpdate = truth * Math.Max(0, Math.Min(1, tmp)) - alpha;
262return maxNumThreads >= 2 && Math.Abs(fullUpdate) > Threshold ? fullUpdate / maxNumThreads : fullUpdate;
385var fullUpdate = truth * Math.Max(0, Math.Min(1, tmp)) - alpha;
386return maxNumThreads >= 2 && Math.Abs(fullUpdate) > Threshold ? fullUpdate / maxNumThreads : fullUpdate;
547return Math.Exp(output) - label * output;
552return (float)Math.Exp(output) - label;
633return output - label * Math.Log(output) + MathUtils.LogGamma(label);
638return output + label / output - Math.Sqrt(label);
640return Math.Pow(output, _index2) / _index2 - label * Math.Pow(output, _index1) / _index1
641- (Math.Pow(label, _index2) / _index2 - label * Math.Pow(label, _index1) / _index1);
651return (float)(Math.Pow(output, _index2) - label * Math.Pow(output, _index1));
Microsoft.ML.Ensemble (2)
Microsoft.ML.Fairlearn (4)
Microsoft.ML.FastTree (129)
Training\DcgCalculator.cs (8)
39DiscountMap[i] = 1.0 / Math.Log(2 + i);
122int maxTrunc = Math.Min(trunc, numDocuments);
145maxDcg += LabelMap[topLabel] / Math.Log(2.0 + t);
371var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumQueries / chunkSize)];
379NdcgRangeWorkerChunkFromScores(dataset, labels, scores, result, start, Math.Min(dataset.NumQueries - start, chunkSize), threadIndex);
467Array.Sort(permutation, 0, Math.Min(count, _secondLevelcomparers[threadIndex].CompareFirstN), _secondLevelcomparers[threadIndex]);
510var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumQueries / chunkSize)];
518OrderingRangeWorkerFromScores(dataset, scores, result, start, Math.Min(dataset.NumQueries - start, chunkSize), threadIndex);
Training\EnsembleCompression\LassoBasedEnsembleCompressor.cs (16)
66_numObservations = Math.Min(_trainSet.NumDocs, maxObservations);
110int selectedDocs = Math.Min(perLabelDocCount[curLabel], currentMax);
176int maxAllowedFeaturesAlongPath = (int)Math.Min(maxAllowedFeaturesPerModel * 1.2, _numFeatures);
192float factor = (float)(1.0 / Math.Sqrt(_numObservations));
207featureStds[j] = Math.Sqrt(VectorUtils.GetDotProduct(_observations[j], _observations[j]));
223float targetStd = (float)Math.Sqrt(VectorUtils.GetDotProduct(_targets, _targets));
239double alf = Math.Pow(Math.Max(Epsilon, flmin), 1.0 / (numberOfLambdas - 1));
243int minimumNumberOfLambdas = Math.Min(MinNumberOFLambdas, numberOfLambdas);
263curLambda = Math.Max(curLambda, Math.Abs(feature2residualCorrelations[j]));
339maxDelta = Math.Max((delta >= 0 ? delta : -delta), maxDelta);
374maxDelta = Math.Max((delta >= 0 ? delta : -delta), maxDelta);
453fit.Lambdas[0] = Math.Exp(2 * Math.Log(fit.Lambdas[1]) - Math.Log(fit.Lambdas[2]));
Microsoft.ML.ImageAnalytics (4)
Microsoft.ML.IntegrationTests (4)
Microsoft.ML.KMeansClustering (8)
Microsoft.ML.LightGbm (9)
Microsoft.ML.Mkl.Components (10)
Microsoft.ML.PCA (2)
Microsoft.ML.Predictor.Tests (6)
Microsoft.ML.ResultProcessor (1)
Microsoft.ML.Samples (17)
Microsoft.ML.SearchSpace (6)
Microsoft.ML.SearchSpace.Tests (6)
Microsoft.ML.StandardTrainers (102)
Microsoft.ML.Sweeper (61)
Algorithms\KdoSweeper.cs (12)
113var numSweeps = Math.Min(numOfCandidates, _args.NumberInitialPopulation - prevRuns.Length);
171double rVar = Math.Pow(VectorUtils.GetStandardDeviation(randomVals), 2) + 1e-10;
250double bandwidthScale = Math.Max(_args.MinimumMutationSpread, correctedVal);
265double eps = Math.Min(Math.Max(child[index], epsCutoff), 1 - epsCutoff);
300double p2 = Math.Pow((4.0 / (d + 2)), p1);
306bandwidthMatrix[i][i] = p2 * stddevs[i] * Math.Pow(n, -p1);
337weights[i] = _args.Simple ? Math.Pow(weights[i], Math.Min(Math.Sqrt(n), 100)) : Math.Pow(weights[i], _args.WeightRescalingPower * currentMaxPerf);
471a[i][j] = i + j == d - 1 ? Math.Sqrt(diagonalCovariance[i][i]) : 0;
Parameters.cs (22)
237? Math.Pow(1.0 * _options.Max / _options.Min, 1.0 / (_options.NumSteps - 1))
239var logMax = Math.Log(_options.Max, logBase);
240var logMin = Math.Log(_options.Min, logBase);
241val = (long)(_options.Min * Math.Pow(logBase, normalizedValue * (logMax - logMin)));
266var logBase = _options.StepSize ?? Math.Pow(1.0 * _options.Max / _options.Min, 1.0 / (_options.NumSteps - 1));
269var maxPlusEpsilon = _options.Max * Math.Sqrt(logBase);
321float logBase = (float)(_options.StepSize ?? Math.Pow(1.0 * _options.Max / _options.Min, 1.0 / (_options.NumSteps - 1)));
322return (float)((Math.Log(valueTyped.Value, logBase) - Math.Log(_options.Min, logBase)) / (Math.Log(_options.Max, logBase) - Math.Log(_options.Min, logBase)));
369? Math.Pow(1.0 * _options.Max / _options.Min, 1.0 / (_options.NumSteps - 1))
371var logMax = Math.Log(_options.Max, logBase);
372var logMin = Math.Log(_options.Min, logBase);
373val = (float)(_options.Min * Math.Pow(logBase, normalizedValue * (logMax - logMin)));
390var logBase = _options.StepSize ?? Math.Pow(1.0 * _options.Max / _options.Min, 1.0 / (_options.NumSteps - 1));
393var maxPlusEpsilon = _options.Max * Math.Sqrt(logBase);
445float logBase = (float)(_options.StepSize ?? Math.Pow(1.0 * _options.Max / _options.Min, 1.0 / (_options.NumSteps - 1)));
446return (float)((Math.Log(valueTyped.Value, logBase) - Math.Log(_options.Min, logBase)) / (Math.Log(_options.Max, logBase) - Math.Log(_options.Min, logBase)));
Microsoft.ML.Sweeper.Tests (1)
Microsoft.ML.TensorFlow (1)
Microsoft.ML.TestFramework (10)
Microsoft.ML.TestFrameworkCommon (1)
Microsoft.ML.Tests (15)
Microsoft.ML.TimeSeries (131)
AdaptiveSingularSpectrumSequenceModeler.cs (36)
44public Double Ratio { get { return Math.Pow(Growth, 1d / TimeSpan); } }
664int evaluationLength = Math.Min(Math.Max(tMat.WindowSize, 200), k);
714error += Math.Abs(series[j] - temp);
757int evaluationLength = Math.Min(Math.Max(tMat.WindowSize, 200), k);
809error += Math.Abs(series[j] - temp);
855_info.ExponentialTrendFactor = Math.Abs(_alpha[0]);
867Double highFrequenceyBoundry = Math.PI / 2;
888if (roots[i].Magnitude > 1 && (Math.Abs(roots[i].Phase) <= eps || Math.Abs(Math.Abs(roots[i].Phase) - Math.PI) <= eps))
897if (roots[i].Magnitude >= 1 && 2 * Math.PI / Math.Abs(roots[i].Phase) > _windowSize)
942if (Math.Abs(sortedComponents[i + 1].Phase - sortedComponents[i].Phase) > 0.05)
994if (Math.Abs(roots[ind].Phase) <= eps)
1003if (Math.Abs(roots[i].Phase) <= eps && 0.9 <= roots[i].Magnitude && i != ind1)
1021maxTrendMagnitude = Math.Min(1, _maxTrendRatio);
1030if (roots[i].Magnitude > 1 && Math.Abs(roots[i].Phase) <= eps)
1033maxTrendMagnitude = Math.Max(maxTrendMagnitude, roots[i].Magnitude);
1036maxNonTrendMagnitude = Math.Max(maxNonTrendMagnitude, roots[i].Magnitude);
1042maxTrendMagnitude = Math.Min(maxTrendMagnitude, _maxTrendRatio);
1046var smallTrendMagnitude = Math.Min(maxTrendMagnitude, (maxTrendMagnitude + 1) / 2);
1051if ((highFrequenceyBoundry < roots[i].Phase && roots[i].Phase < Math.PI - eps) ||
1052(-Math.PI + eps < roots[i].Phase && roots[i].Phase < -highFrequenceyBoundry))
1063if (Math.Abs(phase) <= eps)
1065else if (Math.Abs(phase - Math.PI) <= eps)
1067else if (Math.Abs(phase + Math.PI) <= eps)
1134for (i = Math.Max(0, len - _windowSize + 1); i < len; ++i)
1318var temp = (Single)(1f / Math.Sqrt(_windowSize));
1383for (i = Math.Max(0, len - _windowSize); i < len; ++i)
1444for (j = Math.Max(0, i - _windowSize + 1); j < i; ++j, ++k)
1471sdEditor.Values[i] = (float)Math.Sqrt(sdEditor.Values[i]);
SrCnnEntireAnomalyDetector.cs (27)
504_minimumOriginValue = Math.Min(_minimumOriginValue, value);
505_maximumOriginValue = Math.Max(_maximumOriginValue, value);
523_std = Math.Sqrt((squareSum - (sum * sum) / values.Length) / values.Length);
570_magList[i] = Math.Sqrt(_fftRe[i] * _fftRe[i] + _fftIm[i] * _fftIm[i]);
573_magLogList[i] = Math.Log(_magList[i]);
586_spectralList[i] = Math.Exp(_magLogList[i] - _cumSumList[i]);
614_ifftMagList[i] = Math.Sqrt(_ifftRe[i] * _ifftRe[i] + _ifftIm[i] * _ifftIm[i]);
617AverageFilter(_ifftMagList, Math.Min(_ifftMagList.Length, _judgementWindowSize));
618for (int i = 0; i <= Math.Min(length, _minimumScoreWindowSize); ++i)
620_cumSumList[i] = _cumSumList[Math.Min(length, _minimumScoreWindowSize) - 1];
628score = Math.Min(score, _maximumScore);
629score = Math.Max(score, _minimumScore);
637var zscore = Math.Abs(values[i] - _mean) / _std;
709if (Math.Abs(safeDivisor) < _eps)
713return (Math.Abs(mag - avgMag) / safeDivisor);
783segments.Add(new Tuple<int, int>(start, Math.Max(start, cursor)));
886return Math.Max(Math.Min(expectedValue, value + boundMargin), value - boundMargin);
909int start = Math.Max(idx - step, 0);
910int end = Math.Min(data.Length - 1, idx + step);
924start = Math.Max(idx - step, 0);
925end = Math.Min(data.Length - 1, idx + step);
981int window = Math.Min(data.Length / 3, 512);
993trendSum += Math.Abs(_trends[i]);
1017_units[i] = averageTrendPart + Math.Abs(_trends[i]) * trendFraction;
1119if (Math.Floor(sensitivity) == sensitivity)
1139double distanceFactor = Math.Abs(exp - value) / unit;
Microsoft.ML.TimeSeries.Tests (2)
Microsoft.ML.Tokenizers (24)
Microsoft.ML.Tokenizers.Data.Tests (1)
Microsoft.ML.Tokenizers.Tests (13)
LlamaTests.cs (5)
308for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
846for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
860for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
885for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
899for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
Microsoft.ML.TorchSharp (31)
AutoFormerV2\Anchors.cs (10)
46this.strides = strides != null ? strides : this.pyramidLevels.Select(x => (int)Math.Pow(2, x)).ToArray();
47this.sizes = sizes != null ? sizes : this.pyramidLevels.Select(x => (int)Math.Pow(2, x + 2)).ToArray();
49this.scales = scales != null ? scales : new double[] { Math.Pow(2, 0), Math.Pow(2, 1.0 / 3.0), Math.Pow(2, 2.0 / 3.0) };
70var shape = ((imageShape + Math.Pow(2, x) - 1) / Math.Pow(2, x)).to_type(torch.int32);
98scales ??= new double[] { Math.Pow(2, 0), Math.Pow(2, 1.0 / 3.0), Math.Pow(2, 2.0 / 3.0) };
Microsoft.ML.Transforms (76)
Microsoft.ML.Vision (2)
Microsoft.NET.Build.Containers (2)
Microsoft.NET.HostModel (7)
Microsoft.Net.Http.Headers (2)
Microsoft.NET.ProjectData (2)
Microsoft.NET.ProjectData.Tasks (4)
Microsoft.NET.Sdk.StaticWebAssets.Tasks (1)
Microsoft.Private.Windows.Core (7)
Microsoft.SourceLink.AzureDevOpsServer.Git (2)
Microsoft.SourceLink.AzureRepos.Git (2)
Microsoft.SourceLink.Bitbucket.Git (2)
Microsoft.SourceLink.Common (2)
Microsoft.SourceLink.Gitea (2)
Microsoft.SourceLink.Gitee (2)
Microsoft.SourceLink.GitHub (2)
Microsoft.SourceLink.GitLab (2)
Microsoft.SourceLink.GitWeb (2)
Microsoft.TemplateEngine.Cli (7)
Microsoft.TemplateEngine.Core (14)
Microsoft.TestPlatform.AdapterUtilities (1)
Microsoft.TestPlatform.CommunicationUtilities (6)
Microsoft.TestPlatform.CrossPlatEngine (7)
Microsoft.TestPlatform.Extensions.BlameDataCollector (1)
Microsoft.VisualStudio.TestPlatform.Client (1)
Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger (1)
Microsoft.VisualStudio.TestPlatform.ObjectModel (7)
Mono.Cecil (9)
Mono.Cecil.Mdb (1)
Mono.Cecil.Pdb (1)
MSBuild.Coordinator (5)
mscorlib (1)
NativeIntegrations.DockerCompose (4)
netstandard (1)
NuGet.CommandLine.XPlat (4)
NuGet.Commands (1)
NuGet.Common (3)
NuGet.Configuration (1)
NuGet.DependencyResolver.Core (1)
NuGet.Frameworks (2)
NuGet.PackageManagement (4)
NuGet.Packaging (15)
NuGet.ProjectModel (1)
NuGet.Protocol (1)
NuGet.Resolver (1)
NuGet.Versioning (3)
PresentationBuildTasks (4)
PresentationCore (522)
MS\Internal\Ink\StrokeRenderer.cs (27)
86double delta = Math.Abs(GetAngleDeltaFromLast(strokeNode.PreviousPosition, strokeNode.Position, ref lastAngle));
106if ((Math.Min(prevArea, currArea) / Math.Max(prevArea, currArea)) <= 0.70d)
248double maxExtent = Math.Max(drawingAttributes.Height, drawingAttributes.Width);
249percentIntersect += Math.Min(4.99999d, ((maxExtent / 20d) * 5d));
517bool directionChangedOverAbsoluteThreshold = Math.Abs(delta) > 90d && Math.Abs(delta) < (360d - 90d);
518bool directionChangedOverOverlapThreshold = overlap && !(ignorePressure || strokeNode.PressureFactor == 1f) && Math.Abs(delta) > 30d && Math.Abs(delta) < (360d - 30d);
527if ((Math.Min(prevArea, currArea) / Math.Max(prevArea, currArea)) <= 0.90d)
832double intersectLeft = Math.Max(rect1.Left, rect2.Left);
833double intersectTop = Math.Max(rect1.Top, rect2.Top);
834double intersectWidth = Math.Max((double)(Math.Min(rect1.Right, rect2.Right) - intersectLeft), (double)0);
835double intersectHeight = Math.Max((double)(Math.Min(rect1.Bottom, rect2.Bottom) - intersectTop), (double)0);
845double minArea = Math.Min(rect1Area, rect2Area);
1048angle = Math.PI / 2.0;
1052angle = Math.PI * 3.0 / 2.0;
1063angle = Math.PI;
1070angle = Math.Atan(dy / dx) + Math.PI;
1074angle = Math.Atan(dy / dx) + (2 * Math.PI);
1078angle = Math.Atan(dy / dx);
1083angle = angle * 180 / Math.PI;
MS\Internal\Media3D\GeneralTransform2DTo3DTo2D.cs (19)
495if (!((Math.Max(visEdgeStart.X, visEdgeEnd.X) < Math.Min(uv1.X, uv2.X)) ||
496(Math.Min(visEdgeStart.X, visEdgeEnd.X) > Math.Max(uv1.X, uv2.X)) ||
497(Math.Max(visEdgeStart.Y, visEdgeEnd.Y) < Math.Min(uv1.Y, uv2.Y)) ||
498(Math.Min(visEdgeStart.Y, visEdgeEnd.Y) > Math.Max(uv1.Y, uv2.Y))))
599if (Math.Abs(visUV1.X - visUV2.X) > Math.Abs(visUV1.Y - visUV2.Y))
913if (!((Math.Max(visEdgeStart.X, visEdgeEnd.X) < Math.Min(uv1.X, uv2.X)) ||
914(Math.Min(visEdgeStart.X, visEdgeEnd.X) > Math.Max(uv1.X, uv2.X)) ||
915(Math.Max(visEdgeStart.Y, visEdgeEnd.Y) < Math.Min(uv1.Y, uv2.Y)) ||
916(Math.Min(visEdgeStart.Y, visEdgeEnd.Y) > Math.Max(uv1.Y, uv2.Y))))
1083closestIntersection = ((currClosest - edges[i]._p1Transformed).Length / Math.Sqrt(denom) *
MS\Internal\TextFormatting\LineServicesCallbacks.cs (14)
425lstTextMetrics.dvAscent = (int)Math.Round(typeface.Baseline(store.Pap.EmSize, Constants.DefaultIdealToReal, store.Settings.TextSource.PixelsPerDip, fullText.TextFormattingMode));
426lstTextMetrics.dvMultiLineHeight = (int)Math.Round(typeface.LineSpacing(store.Pap.EmSize, Constants.DefaultIdealToReal, store.Settings.TextSource.PixelsPerDip, fullText.TextFormattingMode));
686ulInfo.dvpFirstUnderlineOffset = (int)Math.Round(lsrun.EmSize * -underlinePositionInEm);
687ulInfo.dvpFirstUnderlineSize = (int)Math.Round(lsrun.EmSize * underlineThicknessInEm);
740stInfo.dvpLowerStrikethroughOffset = (int)Math.Round(lsrun.EmSize * strikeThroughPositionInEm);
741stInfo.dvpLowerStrikethroughSize = (int)Math.Round(lsrun.EmSize * strikeThroughThicknessInEm);
935int baselineTop = ptOrigin.y + (int)Math.Round(lsrun.EmSize * strikeThroughPositionInEm);
936int overlineTop = baselineTop - (lsrun.BaselineOffset - (int)Math.Round(lsrun.EmSize * strikeThroughThicknessInEm));
1242penThickness = Math.Abs(penThickness);
1318drawingPenThickness /= Math.Abs(unitValue);
1987int expandedBy = Math.Max(0, interWordAdjustTo - adjustedCharWidth);
1994pplsAdjustRight[0][i] = Math.Max(0, adjustedCharWidth - interWordAdjustTo);
2120pplsCompressionRight[0][igi + i] = Math.Max(0, glyphAdvance - interWordCompressTo);
2253int expandedBy = Math.Max(0, interWordExpandTo - glyphAdvance);
MS\Internal\TextFormatting\SimpleTextLine.cs (10)
288realHeight = Math.Max(realHeight, run.Height);
289realAscent = Math.Max(realAscent, run.Baseline);
290realDescent = Math.Max(realDescent, run.Height - run.Baseline);
325_height = formatter.IdealToReal((int)Math.Round(pap.DefaultTypeface.LineSpacing(pap.EmSize, Constants.DefaultIdealToReal, PixelsPerDip, _settings.TextFormattingMode)), PixelsPerDip);
326_baselineOffset = formatter.IdealToReal((int)Math.Round(pap.DefaultTypeface.Baseline(pap.EmSize, Constants.DefaultIdealToReal, PixelsPerDip, _settings.TextFormattingMode)), PixelsPerDip);
360_idealOffsetUnRounded = (int)Math.Round((paragraphWidth - idealWidthAtTrailing) * 0.5);
837int first = Math.Max(ich, dcp) + _cpFirst;
838int afterLast = Math.Min(ich + run.Length, dcp + textLength) + _cpFirst;
1205cpVisible = Math.Max(cpRunStart, cp);
1237cpVisible = Math.Min(cpRunEnd, cp);
MS\Internal\TextFormatting\TextStore.cs (16)
508int effectedRangeStart = Math.Max(cpFetched - offset, bounds[0].Position);
509int effectedRangeEnd = Math.Min(cpFetched - offset + runInfo.Length, bounds[bounds.Length - 1].Position);
519int currentRangeEnd = Math.Min(bounds[i].Position, effectedRangeEnd);
553currentPosition = Math.Max(currentPosition, bounds[i + 1].Position);
1121int runLength = Math.Min(span.length, cchToAdd - ichRun);
1209int first = limit - Math.Min(charRange.Length, limitCp - firstCp);
1292int spanLength = Math.Min(runInfoSpanRider.Length, textEffectsSpanRider.Length);
1293int ichEnd = Math.Min(ichRun + spanLength, cchUniform);
1563(int)Math.Round(realToIdeal * runInfo.TextRun.Properties.FontRenderingEmSize),
1718(int)Math.Round(realToIdeal * runInfo.TextRun.Properties.FontRenderingEmSize),
1957textTop = Math.Max(textTop, lsrun.BaselineOffset);
1958textBottom = Math.Max(textBottom, lsrun.Descent);
1978textBottom = Math.Max(textBottom, lsrun.Height + top);
1982textBottom = Math.Max(textBottom, lsrun.Height + textTop);
2046cellAscent = Math.Max(cellAscent, lsrun.BaselineOffset - move);
2047cellDescent = Math.Max(cellDescent, lsrun.Descent + move);
System\Windows\Input\Stylus\Wisp\WispTabletDevice.cs (12)
271Size mouseDragDefault = new Size(Math.Max(1, SafeSystemMetrics.DragDeltaX / 2),
272Math.Max(1, SafeSystemMetrics.DragDeltaY / 2));
273Size mouseDoubleTapDefault = new Size(Math.Max(1, SafeSystemMetrics.DoubleClickDeltaX / 2),
274Math.Max(1, SafeSystemMetrics.DoubleClickDeltaY / 2));
284_cancelSize = new Size((int)Math.Round((ScreenSize.Width * stylusLogic.CancelDelta) / dwXValue),
285(int)Math.Round((ScreenSize.Height * stylusLogic.CancelDelta) / dwYValue));
289_cancelSize.Width = Math.Max(mouseDragDefault.Width, _cancelSize.Width);
290_cancelSize.Height = Math.Max(mouseDragDefault.Height, _cancelSize.Height);
292_doubleTapSize = new Size((int)Math.Round((ScreenSize.Width * stylusLogic.DoubleTapDelta) / dwXValue),
293(int)Math.Round((ScreenSize.Height * stylusLogic.DoubleTapDelta) / dwYValue));
297_doubleTapSize.Width = Math.Max(mouseDoubleTapDefault.Width, _doubleTapSize.Width);
298_doubleTapSize.Height = Math.Max(mouseDoubleTapDefault.Height, _doubleTapSize.Height);
System\Windows\Media\FormattedText.cs (21)
324i = Math.Min(limit, i + formatRider.Length);
397i = Math.Min(limit, i + formatRider.Length);
451i = Math.Min(limit, i + formatRider.Length);
503i = Math.Min(limit, i + formatRider.Length);
561i = Math.Min(limit, i + formatRider.Length);
619i = Math.Min(limit, i + formatRider.Length);
669i = Math.Min(limit, i + formatRider.Length);
720i = Math.Min(limit, i + formatRider.Length);
771i = Math.Min(limit, i + formatRider.Length);
821i = Math.Min(limit, i + formatRider.Length);
952return _that._maxTextWidths[Math.Min(line, _that._maxTextWidths.Length - 1)];
1091Math.Min(textSourcePosition + line.Length - 1, _that._text.Length - 1)
1602int x0 = Math.Max(enumerator.Position, startIndex);
1603int x1 = Math.Min(enumerator.Position + enumerator.Length, startIndex + count);
1754accBlackBoxLeft = Math.Min(accBlackBoxLeft, blackBoxLeft);
1755accBlackBoxRight = Math.Max(accBlackBoxRight, blackBoxRight);
1756accBlackBoxBottom = Math.Max(accBlackBoxBottom, blackBoxBottom);
1757accBlackBoxTop = Math.Min(accBlackBoxTop, blackBoxTop);
1763metrics.Width = Math.Max(metrics.Width, currentLine.Width);
1764metrics.WidthIncludingTrailingWhitespace = Math.Max(metrics.WidthIncludingTrailingWhitespace, currentLine.WidthIncludingTrailingWhitespace);
1765lineStartOfLongestLine = Math.Min(lineStartOfLongestLine, currentLine.Start);
System\Windows\Media3D\Quaternion.cs (34)
69double angleInRadians = angleInDegrees * (Math.PI / 180.0);
73Vector3D v = (axisOfRotation / length) * Math.Sin(0.5 * angleInRadians);
77_w = Math.Cos(0.5 * angleInRadians);
141double msin = Math.Sqrt(_x*_x + _y*_y + _z*_z);
150double maxcoeff = Math.Max(Math.Abs(_x),Math.Max(Math.Abs(_y),Math.Abs(_z)));
154msin = Math.Sqrt(x*x + y*y + z*z);
160return Math.Atan2(msin,mcos) * (360.0 / Math.PI);
240double rmax = 1.0/Max(Math.Abs(_x),
241Math.Abs(_y),
242Math.Abs(_z),
243Math.Abs(_w));
251double normInverse = 1.0 / Math.Sqrt(norm2);
425double max = Math.Max(Math.Max(Math.Abs(_x),Math.Abs(_y)),
426Math.Max(Math.Abs(_z),Math.Abs(_w)));
433double smallLength = Math.Sqrt(x*x+y*y+z*z+w*w);
437return Math.Sqrt(norm2);
541double theta = t * Math.PI;
543scaleFrom = Math.Cos(theta);
544scaleTo = Math.Sin(theta);
549double omega = Math.Acos(cosOmega);
550double sinOmega = Math.Sqrt(1.0 - cosOmega*cosOmega);
551scaleFrom = Math.Sin((1.0 - t) * omega) / sinOmega;
552scaleTo = Math.Sin(t * omega) / sinOmega;
560double lengthOut = lengthFrom * Math.Pow(lengthTo/lengthFrom, t);
System\Windows\Media3D\Rect3D.cs (18)
76_x = Math.Min(point1._x, point2._x);
77_y = Math.Min(point1._y, point2._y);
78_z = Math.Min(point1._z, point2._z);
79_sizeX = Math.Max(point1._x, point2._x) - _x;
80_sizeY = Math.Max(point1._y, point2._y) - _y;
81_sizeZ = Math.Max(point1._z, point2._z) - _z;
417double x = Math.Max(_x, rect._x);
418double y = Math.Max(_y, rect._y);
419double z = Math.Max(_z, rect._z);
420_sizeX = Math.Min(_x + _sizeX, rect._x + rect._sizeX) - x;
421_sizeY = Math.Min(_y + _sizeY, rect._y + rect._sizeY) - y;
422_sizeZ = Math.Min(_z + _sizeZ, rect._z + rect._sizeZ) - z;
455double x = Math.Min(_x, rect._x);
456double y = Math.Min(_y, rect._y);
457double z = Math.Min(_z, rect._z);
458_sizeX = Math.Max(_x + _sizeX, rect._x + rect._sizeX) - x;
459_sizeY = Math.Max(_y + _sizeY, rect._y + rect._sizeY) - y;
460_sizeZ = Math.Max(_z + _sizeZ, rect._z + rect._sizeZ) - z;
PresentationFramework (1120)
MS\Internal\Documents\DocumentGrid.cs (18)
315if (Math.Abs(pageNumber - _firstVisiblePageNumber) > 1)
576double clippedHorizontalOffset = Math.Min(_horizontalOffset, ExtentWidth - ViewportWidth);
577clippedHorizontalOffset = Math.Max(clippedHorizontalOffset, 0.0);
619double clippedVerticalOffset = Math.Min(_verticalOffset, ExtentHeight - ViewportHeight);
620clippedVerticalOffset = Math.Max(clippedVerticalOffset, 0.0);
1207pageOffset = new Point(Math.Max(ViewportWidth, ExtentWidth) - (xOffset + pageSize.Width), yOffset);
1434visiblePages.Add(_childrenCollection[_firstPageVisualIndex + j - Math.Max(0, firstPage)]);
1588double centerWidth = Math.Max(ViewportWidth, ExtentWidth);
2209(int)Math.Floor(ViewportWidth /
2214maxColumns = Math.Min(maxColumns, _pageCache.PageCount);
2215maxColumns = Math.Min(maxColumns, DocumentViewerConstants.MaximumMaxPagesAcross);
2226int rows = (int)Math.Floor((double)(_pageCache.PageCount / columns));
2238double aspectDiff = Math.Abs(layoutAspect - viewportAspect);
2347newScale = Math.Max(newScale, CurrentMinimumScale);
2348newScale = Math.Min(newScale, DocumentViewerConstants.MaximumScale);
2417scaleFactor = Math.Min(compensatedViewportWidth / rowWidth, compensatedViewportHeight / rowHeight);
2446scaleFactor = Math.Min(compensatedViewportWidth / rowWidth,
2672Math.Max(0.0, (ExtentWidth - row.RowSize.Width) / 2.0) : 0.0;
MS\Internal\Documents\RowCache.cs (13)
310double roundedOffset = Math.Round(offset, _findOffsetPrecision);
318double rowOffset = Math.Round(_rowCache[i].VerticalOffset, _findOffsetPrecision);
319double rowHeight = Math.Round(_rowCache[i].RowSize.Height, _findOffsetPrecision);
410startOffset = Math.Round(startOffset, _findOffsetPrecision);
411endOffset = Math.Round(endOffset, _findOffsetPrecision);
417double rowOffset = Math.Round(_rowCache[i].VerticalOffset, _findOffsetPrecision);
469_extentWidth = Math.Max(currentRow.RowSize.Width, _extentWidth);
536_layoutColumns = Math.Min(_layoutColumns, PageCache.PageCount);
537_layoutColumns = Math.Max(1, _layoutColumns);
651pivotPage = Math.Max(0, PageCache.PageCount - columns);
979_extentWidth = Math.Max(newRow.RowSize.Width, _extentWidth);
1109_extentWidth = Math.Max(row.RowSize.Width, _extentWidth);
1379_rowSize.Height = Math.Max(pageSize.Height, _rowSize.Height);
MS\Internal\Documents\TextBoxView.cs (32)
452desiredSize.Width = Math.Min(constraint.Width, desiredSize.Width);
453desiredSize.Height = Math.Min(constraint.Height, desiredSize.Height);
646int startOffset = Math.Min(_lineMetrics[_lineMetrics.Count - 1].EndOffset, startPosition.Offset);
647int endOffset = Math.Min(_lineMetrics[_lineMetrics.Count - 1].EndOffset, endPosition.Offset);
654firstLineIndex = Math.Max(firstLineIndex, GetLineIndexFromOffset(startOffset, LogicalDirection.Forward));
655lastLineIndex = Math.Min(lastLineIndex, GetLineIndexFromOffset(endOffset, LogicalDirection.Backward));
724int nextLineIndex = Math.Max(0, Math.Min(_lineMetrics.Count - 1, lineIndex + count));
1742Math.Max(0, Math.Min(_scrollData.ExtentWidth - _scrollData.ViewportWidth, _scrollData.HorizontalOffset)),
1743Math.Max(0, Math.Min(_scrollData.ExtentHeight - _scrollData.ViewportHeight, _scrollData.VerticalOffset)));
1889int endOffset = Math.Min(range.StartIndex + range.PositionsAdded, _host.TextContainer.SymbolCount);
2000int startOffset = Math.Max(_lineMetrics[lineIndex].Offset, unclippedStartOffset);
2001int endOffset = Math.Min(_lineMetrics[lineIndex].EndOffset, unclippedEndOffset);
2096int startOffset = Math.Max(lineStartOffset, unclippedStartOffset);
2097int endOffset = Math.Min(lineEndOffset, unclippedEndOffset);
2156lastLineIndex = (int)Math.Ceiling((viewport.Y + viewport.Height) / _lineHeight) - 1;
2159firstLineIndex = Math.Max(0, Math.Min(firstLineIndex, _lineMetrics.Count - 1));
2160lastLineIndex = Math.Max(0, Math.Min(lastLineIndex, _lineMetrics.Count - 1));
2232desiredSize.Width = Math.Max(desiredSize.Width, line.Width);
2522int lastCoveredCharOffset = range.StartIndex + Math.Max(range.PositionsAdded, range.PositionsRemoved);
2618desiredSize.Width = Math.Max(desiredSize.Width, _lineMetrics[i].Width);
2681int lineIndex = Math.Max(oldLineVisualsIndex, firstLineIndex);
2682int lineCount = Math.Min(oldLastLineIndex, firstLineIndex + count - 1) - lineIndex + 1;
2767count = Math.Max(0, count);
2773count = Math.Min(count, _viewportLineVisuals.Count - start);
2948int rangeStart = Math.Max(viewportStart, selectionStart);
2949int rangeSize = Math.Min(viewportEnd, selectionEnd) - rangeStart;
3085padding = Math.Max(0, viewport.Height - _contentSize.Height);
MS\Internal\Ink\LassoHelper.cs (6)
108double step = Math.Sqrt(MinDistanceSquared / distanceSquared);
228&& DoubleUtil.GreaterThanOrClose(point.X, Math.Min(prevLassoPoint.X, lassoPoint.X))
229&& DoubleUtil.LessThanOrClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X)))
238if (DoubleUtil.GreaterThanOrClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X)))
244if ((0 == i) && DoubleUtil.AreClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X)))
249else if (DoubleUtil.GreaterThanOrClose(point.X, Math.Min(prevLassoPoint.X, lassoPoint.X)))
MS\Internal\PtsHost\ContainerParagraph.cs (13)
504fsrcToFillSubtrack.u = Math.Max(Math.Min(fsrcToFillSubtrack.u, fsrcToFill.u + fsrcToFill.du - 1), fsrcToFill.u);
505fsrcToFillSubtrack.du = Math.Max(fsrcToFillSubtrack.du, 0);
518fsrcToFillSubtrack.v = Math.Max(Math.Min(fsrcToFillSubtrack.v, fsrcToFill.v + fsrcToFill.dv - 1), fsrcToFill.v);
519fsrcToFillSubtrack.dv = Math.Max(fsrcToFillSubtrack.dv, 0);
577dvrUsed = Math.Min(fsrcToFill.dv, dvrUsed);
657urSubtrack = Math.Max(Math.Min(urTrack + mbp.MBPLeft, urTrack + durTrack - 1), urTrack);
658durSubtrack = Math.Max(durTrack - (mbp.MBPLeft + mbp.MBPRight), 0);
781urSubtrack = Math.Max(Math.Min(urTrack + mbp.MBPLeft, urTrack + durTrack - 1), urTrack);
782durSubtrack = Math.Max(durTrack - (mbp.MBPLeft + mbp.MBPRight), 0);
MS\Internal\PtsHost\SubpageParagraph.cs (16)
162subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight));
171subpageHeight = Math.Max(1, subpageHeight - (marginTop + mbp.BPTop));
222dvrUsed = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
223fsrcToFill.du = Math.Max(fsrcToFill.du, fsbbox.fsrc.du + fsbbox.fsrc.u);
266fsbbox.fsrc.du = Math.Max(fsrcToFill.du - (mbp.MarginLeft + mbp.MarginRight), 0);
267fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
342subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight));
410dvrUsed = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
411durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u);
421fsbbox.fsrc.du = Math.Max(durTrack - (mbp.MarginLeft + mbp.MarginRight), 0);
422fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
498subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight));
565dvrUsed = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v);
566durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u);
576fsbbox.fsrc.du = Math.Max(durTrack - (mbp.MarginLeft + mbp.MarginRight), 0);
577fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
MS\Internal\PtsHost\TextParaClient.cs (19)
738int dcpStart = Math.Max(cpStartTextPointer, cpParagraphStart) - cpParagraphStart;
742int dcpEnd = Math.Min(cpEndTextPointer, cpParagraphEnd) - cpParagraphStart;
1407int countVisualsShiftBeforeChange = Math.Min(Math.Max(lineIndexToBeginRemoval - _lineIndexFirstVisual, 0), lineVisuals.Count);
1424int actualLinesToRemove = Math.Min(Math.Max(lineIndexToBeginRemoval - _lineIndexFirstVisual + cLinesToRemove, 0), lineVisuals.Count);
1452int actualLinesToRemove = Math.Min(cLinesToRemove, lineVisuals.Count - (lineIndexToBeginRemoval - _lineIndexFirstVisual));
1872int dcpRangeStartForThisLine = Math.Max(lineDesc.dcpFirst, dcpStart);
1875int cchRangeForThisLine = Math.Max(Math.Min(lineDesc.dcpLim, dcpEnd) - dcpRangeStartForThisLine, 1);
1982int dcpRangeStartForThisElem = Math.Max(elemDesc.dcpFirst, dcpStart);
1985int cchRangeForThisElem = Math.Max(Math.Min(elemDesc.dcpLim, dcpEnd) - dcpRangeStartForThisElem, 1);
2077lineRect.Width = Math.Max(lineVisual.WidthIncludingTrailingWhitespace, 0);
2188elementRect.Width = Math.Max(lineVisual.WidthIncludingTrailingWhitespace, 0);
3126line.GetGlyphRuns(glyphRuns, Math.Max(dcpStart, lineDesc.dcpFirst), Math.Min(dcpEnd, lineDesc.dcpLim));
3188line.GetGlyphRuns(glyphRuns, Math.Max(dcpStart, element.dcpFirst), Math.Min(dcpEnd, element.dcpLim));
System\Windows\Controls\Border.cs (12)
229Size childConstraint = new Size(Math.Max(0.0, constraint.Width - combined.Width),
230Math.Max(0.0, constraint.Height - combined.Height));
642Math.Max(0.0, rt.Width - thick.Left - thick.Right),
643Math.Max(0.0, rt.Height - thick.Top - thick.Bottom));
986LeftTop = Math.Max(0.0, radii.TopLeft - left);
987TopLeft = Math.Max(0.0, radii.TopLeft - top);
988TopRight = Math.Max(0.0, radii.TopRight - top);
989RightTop = Math.Max(0.0, radii.TopRight - right);
990RightBottom = Math.Max(0.0, radii.BottomRight - right);
991BottomRight = Math.Max(0.0, radii.BottomRight - bottom);
992BottomLeft = Math.Max(0.0, radii.BottomLeft - bottom);
993LeftBottom = Math.Max(0.0, radii.BottomLeft - left);
System\Windows\Controls\DataGrid.cs (18)
2617indexToSelect = Math.Min(Items.Count - numSelected - 1, indexToSelect);
5019int newRowCount = Math.Abs(endIndex - startIndex) + 1;
5020int newColumnCount = Math.Abs(endColumnIndex - startColumnIndex) + 1;
5038int previousStartIndex = Math.Min(startIndex, currentCellIndex);
5039int previousRowCount = Math.Abs(currentCellIndex - startIndex) + 1;
5040int previousStartColumnIndex = Math.Min(startColumnIndex, currentCellColumnIndex);
5041int previousColumnCount = Math.Abs(currentCellColumnIndex - startColumnIndex) + 1;
5081_selectedCells.AddRegion(Math.Min(startIndex, endIndex), Math.Min(startColumnIndex, endColumnIndex), newRowCount, newColumnCount);
5679nextDisplayIndex = Math.Max(0, InternalColumns.LastVisibleDisplayIndex);
5760nextRowIndex = Math.Max(0, Items.Count - 1);
5945index = Math.Max(0, Math.Min(numItems - 1, index + (shiftModifier ? -1 : 1)));
6085int jumpDistance = Math.Max(1, (int)scrollHost.ViewportHeight - 1);
6087targetIndex = Math.Max(0, Math.Min(targetIndex, Items.Count - 1));
6530distance = Math.Abs(pt.Y - cellBounds.Top);
6538distance = Math.Abs(pt.X - cellBounds.Left);
System\Windows\Controls\DataGridColumnCollection.cs (24)
748int columnCount = Math.Min(newFrozenCount, Count);
756int columnCount = Math.Min(oldFrozenCount, Count);
946availableStarSpace = Math.Max(0.0, availableStarSpace - columnMinWidth);
1227double displayValue = Math.Max(width.DesiredValue, minWidth);
1267double displayValue = Math.Min(width.DesiredValue, maxWidth);
1335TakeAwayWidthFromColumns(null, Math.Abs(availableSpaceChange), false, newTotalAvailableSpace);
1359column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, width.DesiredValue, Math.Min(width.DesiredValue, maxWidth)));
1381Math.Max(width.DisplayValue - nonRetrievableSpace, changedColumn.MinWidth)));
1453return Math.Max(availableSpace - requiredSpace, 0.0);
1664column.UpdateWidthForStarColumn(Math.Max(columnDesiredWidth, column.MinWidth), columnDesiredWidth, columnDesiredWidth / perStarWidth);
1693double columnExcessWidth = onlyShrinkToDesiredWidth ? width.DisplayValue - Math.Max(width.DesiredValue, column.MinWidth) : width.DisplayValue - column.MinWidth;
1778double maxColumnResizeWidth = expandBeyondDesiredWidth ? column.MaxWidth : Math.Min(width.DesiredValue, column.MaxWidth);
1913column.UpdateWidthForStarColumn(Math.Min(columnDesiredWidth, column.MaxWidth), columnDesiredWidth, columnDesiredWidth / perStarWidth);
2000double usedStarSpace = ComputeStarColumnWidths(Math.Min(expectedStarSpace, sumOfStarMaxWidths));
2001giveAwayWidth = Math.Max(usedStarSpace - expectedStarSpace, 0.0);
2071double lagWidth = Math.Min(width.DesiredValue, columnMaxWidth) - width.DisplayValue;
2102if (DoubleUtil.LessThan(width.DisplayValue, Math.Min(width.DesiredValue, column.MaxWidth)))
2130giveAwayWidth -= Math.Min(contributingSpace, giveAwayWidth);
2137giveAwayWidth = Math.Min(giveAwayWidth, Math.Max(0d, totalSpace - usedSpace));
2184return Math.Min(usedSpace - totalAvailableWidth, takeAwayWidth);
2192takeAwayWidth = Math.Max(0.0, takeAwayWidth - unusedSpace);
2263double usedStarSpace = ComputeStarColumnWidths(Math.Max(expectedStarSpace, sumOfStarMinWidths));
2264takeAwayWidth = Math.Max(usedStarSpace - expectedStarSpace, 0.0);
System\Windows\Controls\DockPanel.cs (10)
216childConstraint = new Size(Math.Max(0.0, constraint.Width - accumulatedWidth),
217Math.Max(0.0, constraint.Height - accumulatedHeight));
237parentHeight = Math.Max(parentHeight, accumulatedHeight + childDesiredSize.Height);
243parentWidth = Math.Max(parentWidth, accumulatedWidth + childDesiredSize.Width);
250parentWidth = Math.Max(parentWidth, accumulatedWidth);
251parentHeight = Math.Max(parentHeight, accumulatedHeight);
281Math.Max(0.0, arrangeSize.Width - (accumulatedLeft + accumulatedRight)),
282Math.Max(0.0, arrangeSize.Height - (accumulatedTop + accumulatedBottom)) );
295rcChild.X = Math.Max(0.0, arrangeSize.Width - accumulatedRight);
306rcChild.Y = Math.Max(0.0, arrangeSize.Height - accumulatedBottom);
System\Windows\Controls\FlowDocumentScrollViewer.cs (8)
584Math.Max(ia.OriginWidth, pagePadding.Left),
585Math.Max(ia.OriginHeight, pagePadding.Top),
586Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right),
587Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom));
623Zoom = Math.Min(Zoom + ZoomIncrement, MaxZoom);
635Zoom = Math.Max(Zoom - ZoomIncrement, MinZoom);
701SetCurrentValueInternal(ZoomProperty, Math.Min(Zoom + ZoomIncrement, MaxZoom));
705SetCurrentValueInternal(ZoomProperty, Math.Max(Zoom - ZoomIncrement, MinZoom));
System\Windows\Controls\Grid.cs (69)
422gridDesiredSize.Width = Math.Max(gridDesiredSize.Width, child.DesiredSize.Width);
423gridDesiredSize.Height = Math.Max(gridDesiredSize.Height, child.DesiredSize.Height);
953ColumnIndex = Math.Min(GetColumn(child), DefinitionsU.Length - 1),
956RowIndex = Math.Min(GetRow(child), DefinitionsV.Length - 1)
962cell.ColumnSpan = Math.Min(GetColumnSpan(child), DefinitionsU.Length - cell.ColumnIndex);
966cell.RowSpan = Math.Min(GetRowSpan(child), DefinitionsV.Length - cell.RowIndex);
1143userMinSize = Math.Max(userMinSize, Math.Min(userSize, userMaxSize));
1167definitions[i].MeasureSize = Math.Max(userMinSize, Math.Min(userSize, userMaxSize));
1267DefinitionsU[PrivateCells[i].ColumnIndex].UpdateMinSize(Math.Min(children[i].DesiredSize.Width, DefinitionsU[PrivateCells[i].ColumnIndex].UserMaxSize));
1284DefinitionsV[PrivateCells[i].RowIndex].UpdateMinSize(Math.Min(children[i].DesiredSize.Height, DefinitionsV[PrivateCells[i].RowIndex].UserMaxSize));
1505double maxSize = Math.Max(definitions[i].UserMaxSize, minSize);
1557double newMinSize = Math.Min(sizeToDistribute / (count - i), tempDefinitions[i].PreferredSize);
1587tempDefinitions[i].UpdateMinSize(Math.Min(newMinSize, tempDefinitions[i].SizeCache));
1598tempDefinitions[i].UpdateMinSize(Math.Min(newMinSize, tempDefinitions[i].SizeCache));
1709starValue = Math.Min(starValue, c_starClip);
1713double maxSize = Math.Max(definitions[i].MinSize, definitions[i].UserMaxSize);
1714maxSize = Math.Min(maxSize, c_starClip);
1752double userSize = Math.Max(availableSize - takenSize, 0.0) * (starValue / tempDefinitions[i].SizeCache);
1753resolvedSize = Math.Min(userSize, tempDefinitions[i].UserMaxSize);
1754resolvedSize = Math.Max(tempDefinitions[i].MinSize, resolvedSize);
1815double power = Math.Floor(Math.Log(Double.MaxValue / maxStar / starCount, 2.0));
1818scale = Math.Pow(2.0, power - 4.0); // -4 is just for paranoia
1866double effectiveMaxSize = Math.Max(def.MinSize, def.UserMaxSize);
1938resolvedSize = Math.Max(resolvedDef.MinSize, resolvedDef.UserMaxSize);
2056double resolvedSize = (def.MeasureSize > 0.0) ? Math.Max(availableSize - takenSize, 0.0) * (def.MeasureSize / def.SizeCache) : 0.0;
2059resolvedSize = Math.Min(resolvedSize, def.UserMaxSize);
2060resolvedSize = Math.Max(def.MinSize, resolvedSize);
2149starValue = Math.Min(starValue, c_starClip);
2153double maxSize = Math.Max(definitions[i].MinSizeForArrange, definitions[i].UserMaxSize);
2154maxSize = Math.Min(maxSize, c_starClip);
2194definitions[i].SizeCache = Math.Max(definitions[i].MinSizeForArrange, Math.Min(userSize, userMaxSize));
2239double userSize = Math.Max(finalSize - allPreferredArrangeSize, 0.0) * (starValue / definitions[definitionIndices[i]].SizeCache);
2240resolvedSize = Math.Min(userSize, definitions[definitionIndices[i]].UserMaxSize);
2241resolvedSize = Math.Max(definitions[definitionIndices[i]].MinSizeForArrange, resolvedSize);
2266final = Math.Max(final, definitions[definitionIndex].MinSizeForArrange);
2267final = Math.Min(final, definitions[definitionIndex].SizeCache);
2273final = Math.Max(final, definitions[definitionIndex].MinSizeForArrange);
2274final = Math.Min(final, definitions[definitionIndex].SizeCache);
2307final = Math.Max(final, definition.MinSizeForArrange);
2323final = Math.Max(final, definition.MinSizeForArrange);
2394double power = Math.Floor(Math.Log(Double.MaxValue / maxStar / starCount, 2.0));
2397scale = Math.Pow(2.0, power - 4.0); // -4 is just for paranoia
2441double effectiveMaxSize = Math.Max(def.MinSizeForArrange, def.UserMaxSize);
2480def.SizeCache = Math.Max(def.MinSizeForArrange, Math.Min(userSize, userMaxSize));
2549resolvedSize = Math.Max(resolvedDef.MinSizeForArrange, resolvedDef.UserMaxSize);
2681double resolvedSize = (def.MeasureSize > 0.0) ? Math.Max(finalSize - takenSize, 0.0) * (def.MeasureSize / def.SizeCache) : 0.0;
2684resolvedSize = Math.Min(resolvedSize, def.UserMaxSize);
2685resolvedSize = Math.Max(def.MinSizeForArrange, resolvedSize);
2776final = Math.Max(final, definition.MinSizeForArrange);
2792final = Math.Max(final, definition.MinSizeForArrange);
2834double minPower = Math.Floor(Math.Log(minRatio, 2.0));
2835double maxPower = Math.Floor(Math.Log(maxRatio, 2.0));
2836double f = Math.Pow(2.0, Math.Floor((minPower + maxPower) / 2.0));
2915Array.Clear(extData.TempDefinitions, 0, Math.Max(DefinitionsU.Length, DefinitionsV.Length));
3120int requiredLength = Math.Max(DefinitionsU.Length, DefinitionsV.Length) * 2;
3153int requiredLength = Math.Max(Math.Max(DefinitionsU.Length, DefinitionsV.Length), 1) * 2;
3171int requiredLength = Math.Max(DefinitionsU.Length, DefinitionsV.Length);
3263return (Math.Abs(d) < c_epsilon);
3274return (Math.Abs(d1 - d2) < c_epsilon);
System\Windows\Controls\GridSplitter.cs (13)
503_resizeData.SplitterLength = Math.Min(ActualWidth, ActualHeight);
655horizontalChange = Math.Round(horizontalChange / dragIncrement) * dragIncrement;
656verticalChange = Math.Round(verticalChange / dragIncrement) * dragIncrement;
663_resizeData.Adorner.OffsetX = Math.Min(Math.Max(horizontalChange, _resizeData.MinChange), _resizeData.MaxChange);
667_resizeData.Adorner.OffsetY = Math.Min(Math.Max(verticalChange, _resizeData.MinChange), _resizeData.MaxChange);
801definition1Min = Math.Max(definition1Min, _resizeData.SplitterLength);
805definition2Min = Math.Max(definition2Min, _resizeData.SplitterLength);
811minDelta = -Math.Min(definition1Len - definition1Min, definition2Max - definition2Len);
812maxDelta = Math.Min(definition1Max - definition1Len, definition2Len - definition2Min);
920delta = Math.Min(Math.Max(delta, min), max);
System\Windows\Controls\GridViewHeaderRowPresenter.cs (8)
258double childConstraintWidth = Math.Max(0.0, constraint.Width - accumulatedWidth);
280childConstraintWidth = Math.Min(childConstraintWidth, column.DesiredWidth);
288childConstraintWidth = Math.Min(childConstraintWidth, column.Width);
295maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
302maxHeight = Math.Max(maxHeight, _paddingHeader.DesiredSize.Height);
351double childArrangeWidth = Math.Min(remainingWidth, ((column.State == ColumnMeasureState.SpecificWidth) ? column.Width : column.DesiredWidth));
385rect = new Rect(accumulatedWidth, 0.0, Math.Max(remainingWidth, 0.0), arrangeSize.Height);
1217return (DoubleUtil.GreaterThan(Math.Abs(currentPos.X - originalPos.X), c_thresholdX));
System\Windows\Controls\Primitives\DataGridColumnHeadersPresenter.cs (10)
116desiredSize.Width = Math.Max(desiredSize.Width, indicatorSize.Width);
117desiredSize.Height = Math.Max(desiredSize.Height, indicatorSize.Height);
124desiredSize.Width = Math.Max(desiredSize.Width, indicatorSize.Width);
125desiredSize.Height = Math.Max(desiredSize.Height, indicatorSize.Height);
128desiredSize.Width = Math.Min(availableSize.Width, desiredSize.Width);
148childRect.Width = Math.Max(finalSize.Width, dataGrid.CellsPanelActualWidth);
631return DoubleUtil.GreaterThan(Math.Abs(currentPos.X - originalPos.X), SystemParameters.MinimumHorizontalDragDistance);
680height = Math.Max(_draggingSrcColumnHeader.RenderSize.Height, _columnHeaderDragIndicator.Height);
902columnEstimatedWidth = Math.Max(averageColumnWidth, column.MinWidth);
903columnEstimatedWidth = Math.Min(columnEstimatedWidth, column.MaxWidth);
System\Windows\Controls\Primitives\Popup.cs (26)
2108if (Math.Abs(score - childArea) < Tolerance)
2134if (Math.Abs(intersection.Width - childBounds.Width) > Tolerance ||
2135Math.Abs(intersection.Height - childBounds.Height) > Tolerance)
2149if (!IsTransparent || double.IsNaN(horizontalAxis.Y) || Math.Abs(horizontalAxis.Y) < Tolerance)
2161else if (IsTransparent && Math.Abs(horizontalAxis.X) < Tolerance)
2184if (!IsTransparent || double.IsNaN(verticalAxis.X) || Math.Abs(verticalAxis.X) < Tolerance)
2195else if (IsTransparent && Math.Abs(verticalAxis.Y) < Tolerance)
2250if (!IsTransparent || double.IsNaN(verticalAxis.X) || Math.Abs(verticalAxis.X) < Tolerance)
2252limitSize.Height = Math.Max(0.0, Math.Max(screenBounds.Bottom - targetBounds.Bottom, targetBounds.Top - screenBounds.Top));
2254else if (IsTransparent && Math.Abs(verticalAxis.Y) < Tolerance)
2256limitSize.Width = Math.Max(0.0, Math.Max(screenBounds.Right - targetBounds.Right, targetBounds.Left - screenBounds.Left));
2272if (!IsTransparent || double.IsNaN(horizontalAxis.X) || Math.Abs(horizontalAxis.Y) < Tolerance)
2274limitSize.Width = Math.Max(0.0, Math.Max(screenBounds.Right - targetBounds.Right, targetBounds.Left - screenBounds.Left));
2276else if (IsTransparent && Math.Abs(horizontalAxis.X) < Tolerance)
2278limitSize.Height = Math.Max(0.0, Math.Max(screenBounds.Bottom - targetBounds.Bottom, targetBounds.Top - screenBounds.Top));
2628desiredSize.Width = Math.Min(desiredSize.Width, screenBounds.Width);
2629desiredSize.Width = Math.Min(desiredSize.Width, limitSize.Width);
2633desiredSize.Height = Math.Min(desiredSize.Height, screenBounds.Height);
2634desiredSize.Height = Math.Min(desiredSize.Height, maxHeight);
2635desiredSize.Height = Math.Min(desiredSize.Height, limitSize.Height);
2708return new Rect(mousePoint.x, mousePoint.y - 1, Math.Max(0, cursorWidth - hotX), Math.Max(0, cursorHeight - hotY + 2));
System\Windows\Controls\ScrollViewer.cs (17)
400get { return Math.Max(0.0, ExtentWidth - ViewportWidth); }
408get { return Math.Max(0.0, ExtentHeight - ViewportHeight); }
1745DoubleUtil.LessThan(Math.Abs(unusedX), PanningInfo.PreFeedbackTranslationX))
1753DoubleUtil.LessThan(Math.Abs(unusedY), PanningInfo.PreFeedbackTranslationY))
1798double newUnused = Math.Max(unused + delta, 0);
1807double newUnused = Math.Min(unused + delta, 0);
1818Math.Round(PanningRatio * cumulativeTranslation / _panningInfo.DeltaPerHorizontalOffet));
1828Math.Round(PanningRatio * cumulativeTranslation / _panningInfo.DeltaPerVerticalOffset));
1841if (Math.Abs(Environment.TickCount - _panningInfo.InertiaBoundaryBeginTimestamp) < PanningInfo.InertiaBoundryMinimumTicks)
1846return (DoubleUtil.GreaterThanOrClose(Math.Abs(_panningInfo.UnusedTranslation.X), PanningInfo.MaxInertiaBoundaryTranslation) ||
1847DoubleUtil.GreaterThanOrClose(Math.Abs(_panningInfo.UnusedTranslation.Y), PanningInfo.MaxInertiaBoundaryTranslation));
1866bool validX = (DoubleUtil.GreaterThan(Math.Abs(translation.X), PanningInfo.PrePanTranslation));
1867bool validY = (DoubleUtil.GreaterThan(Math.Abs(translation.Y), PanningInfo.PrePanTranslation));
1877bool biggerX = (DoubleUtil.GreaterThanOrClose(Math.Abs(translation.X), Math.Abs(translation.Y)));
1890bool biggerY = (DoubleUtil.GreaterThanOrClose(Math.Abs(translation.Y), Math.Abs(translation.X)));
System\Windows\Controls\SinglePageViewer.cs (6)
690Math.Max(ia.OriginWidth, pagePadding.Left),
691Math.Max(ia.OriginHeight, pagePadding.Top),
692Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right),
693Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom));
731SetCurrentValueInternal(ZoomProperty, Math.Min(Zoom + ZoomIncrement, MaxZoom));
743SetCurrentValueInternal(ZoomProperty, Math.Max(Zoom - ZoomIncrement, MinZoom));
System\Windows\Controls\Slider.cs (15)
987valueToSize = Math.Max(0.0, (trackSize.Width - thumbSize.Width) / range);
993Canvas.SetLeft(rangeElement, (thumbSize.Width * 0.5) + Math.Max(Maximum - SelectionEnd, 0) * valueToSize);
997Canvas.SetLeft(rangeElement, (thumbSize.Width * 0.5) + Math.Max(SelectionStart - Minimum, 0) * valueToSize);
1009valueToSize = Math.Max(0.0, (trackSize.Height - thumbSize.Height) / range);
1015Canvas.SetTop(rangeElement, (thumbSize.Height * 0.5) + Math.Max(SelectionStart - Minimum, 0) * valueToSize);
1019Canvas.SetTop(rangeElement, (thumbSize.Height * 0.5) + Math.Max(Maximum - SelectionEnd,0) * valueToSize);
1052valueToSize = Math.Max(0.0, (trackSize.Width - thumbSize.Width) / range);
1076valueToSize = Math.Max(0.0, (trackSize.Height - thumbSize.Height) / range);
1184previous = Minimum + (Math.Round(((value - Minimum) / TickFrequency)) * TickFrequency);
1185next = Math.Min(Maximum, previous + TickFrequency);
1205double next = SnapToTick(Math.Max(this.Minimum, Math.Min(this.Maximum, value + direction)));
1243double tickNumber = Math.Round((value - Minimum) / TickFrequency);
1401this.SetCurrentValueInternal(ValueProperty, Math.Max(this.Minimum, Math.Min(this.Maximum, snappedValue)));
System\Windows\Controls\Stack.cs (15)
593stackDesiredSize.Height = Math.Max(stackDesiredSize.Height, childDesiredSize.Height);
598stackDesiredSize.Width = Math.Max(stackDesiredSize.Width, childDesiredSize.Width);
658offset.Y = Math.Max(0, Math.Min(offset.Y, extent.Height - viewport.Height));
666offset.X = Math.Max(0, Math.Min(offset.X, extent.Width - viewport.Width));
671stackDesiredSize.Width = Math.Min(stackDesiredSize.Width, constraint.Width);
672stackDesiredSize.Height = Math.Min(stackDesiredSize.Height, constraint.Height);
750rcChild.Height = Math.Max(arrangeSize.Height, child.DesiredSize.Height);
757rcChild.Width = Math.Max(arrangeSize.Width, child.DesiredSize.Width);
891double left = Math.Max(targetRectOffset, minPhysicalOffset);
892targetRectSize = Math.Max(Math.Min(targetRectSize + targetRectOffset, minPhysicalOffset + viewportSize) - left, 0);
990iNewOffset = Math.Max(Math.Min(numberOfItems - 1, iNewOffset), 0);
System\Windows\Controls\TextBlock.cs (12)
1259Size contentSize = new Size(Math.Max(0.0, constraint.Width - (padding.Left + padding.Right)),
1260Math.Max(0.0, constraint.Height - (padding.Top + padding.Bottom)));
1299desiredSize.Width = Math.Max(desiredSize.Width, line.GetCollapsedWidth());
1522double contentBottom = Math.Max(0.0, RenderSize.Height - Padding.Bottom);
1956Size contentSize = new Size(Math.Max(0.0, _referenceSize.Width - (padding.Left + padding.Right)),
1957Math.Max(0.0, _referenceSize.Height - (padding.Top + padding.Bottom)));
2309int dcpStart = Math.Max(dcpLineStart, dcpPositionStart);
2310int dcpEnd = Math.Min(dcpLineEnd, dcpPositionEnd);
3096Size contentSize = new Size(Math.Max(0.0, computedSize.Width - (padding.Left + padding.Right)),
3097Math.Max(0.0, computedSize.Height - (padding.Top + padding.Bottom)));
3146double contentBottom = Math.Max(0.0, RenderSize.Height - Padding.Bottom);
3176width = Math.Max(0.0, width - paddingWidth);
System\Windows\Controls\VirtualizedCellInfoCollection.cs (12)
608int left = Math.Max(Left, region.Left);
609int top = Math.Max(Top, region.Top);
610int right = Math.Min(Right, region.Right);
611int bottom = Math.Min(Bottom, region.Bottom);
681Left = Math.Min(Left, region.Left);
682Top = Math.Min(Top, region.Top);
683Right = Math.Max(prevRight, region.Right);
684Bottom = Math.Max(prevBottom, region.Bottom);
724int top = Math.Max(Top, region.Top);
725int bottom = Math.Min(Bottom, region.Bottom);
732int top = Math.Max(Top, region.Top);
733int bottom = Math.Min(Bottom, region.Bottom);
System\Windows\Controls\VirtualizingStackPanel.cs (177)
510double delta = Math.Abs(scrollX - oldViewportOffset.X);
523_scrollData._offset.X = Math.Floor(_scrollData._offset.X);
524_scrollData._computedOffset.X = Math.Floor(_scrollData._computedOffset.X);
638double delta = Math.Abs(scrollY - oldViewportOffset.Y);
651_scrollData._offset.Y = Math.Floor(_scrollData._offset.Y);
652_scrollData._computedOffset.Y = Math.Floor(_scrollData._computedOffset.Y);
2319double factor = Math.Min(1.0, isHorizontal ? viewport.Width / extendedViewport.Width : viewport.Height / extendedViewport.Height);
2320int calcItemsInViewportCount = (int)Math.Ceiling(factor * _itemsInExtendedViewportCount);
2321excludeCount = Math.Max(excludeCount,
2615double spanBeforeViewport = Math.Max(isHorizontal ? viewport.X : viewport.Y, 0.0);
2672_firstItemInExtendedViewportIndex = Math.Max(_firstItemInExtendedViewportIndex - 1, 0);
2674_firstItemInExtendedViewportChildIndex = Math.Max(_firstItemInExtendedViewportChildIndex, 0);
3369arrangeLength = Math.Max(isHorizontal ? arrangeSize.Height : arrangeSize.Width, arrangeLength);
4735pixelSizeBeforeViewport = Math.Max(pixelSizeBeforeViewport, Math.Abs(_viewport.X - _extendedViewport.X));
4739logicalSizeBeforeViewport = Math.Max(logicalSizeBeforeViewport, Math.Abs(_viewport.X - _extendedViewport.X));
4771extendedViewport.Width = Math.Max(extendedViewport.Width + extendedViewport.X, 0.0);
4782extendedViewport.Width = Math.Max(_scrollData._extent.Width - extendedViewport.X, 0.0);
4811extendedViewport.Width = Math.Max(extendedViewport.Width / approxSizeOfLogicalUnit + extendedViewport.X, 0.0) * approxSizeOfLogicalUnit;
4822extendedViewport.Width = Math.Max(_scrollData._extent.Width - extendedViewport.X, 0.0) * approxSizeOfLogicalUnit;
4851pixelSizeBeforeViewport = Math.Max(pixelSizeBeforeViewport, Math.Abs(_viewport.Y - _extendedViewport.Y));
4855logicalSizeBeforeViewport = Math.Max(logicalSizeBeforeViewport, Math.Abs(_viewport.Y - _extendedViewport.Y));
4887extendedViewport.Height = Math.Max(extendedViewport.Height + extendedViewport.Y, 0.0);
4898extendedViewport.Height = Math.Max(_scrollData._extent.Height - extendedViewport.Y, 0.0);
4927extendedViewport.Height = Math.Max(extendedViewport.Height / approxSizeOfLogicalUnit + extendedViewport.Y, 0.0) * approxSizeOfLogicalUnit;
4938extendedViewport.Height = Math.Max(_scrollData._extent.Height - extendedViewport.Y, 0.0) * approxSizeOfLogicalUnit;
4950double factor = Math.Max(1.0, isHorizontal ? extendedViewport.Width / viewport.Width : extendedViewport.Height / viewport.Height);
4951int calcItemsInExtendedViewportCount = (int)Math.Ceiling(factor * _actualItemsInExtendedViewportCount);
4952itemsInExtendedViewportCount = Math.Max(calcItemsInExtendedViewportCount, itemsInExtendedViewportCount);
5063viewport.Width = Math.Max(viewport.Width - sizeAfterStartViewportEdge, 0);
5067cacheBeforeSize = Math.Max(cacheBeforeSize - sizeBeforeStartViewportEdge, 0);
5071cacheBeforeSize = Math.Max(cacheBeforeSize - Math.Floor(logicalSize.Width * sizeBeforeStartViewportEdge / pixelSize.Width), 0);
5098viewport.Width = Math.Max(0, parentViewport.Width - pixelSize.Width);
5113cacheAfterSize = Math.Max(cacheAfterSize - sizeAfterEndViewportEdge, 0);
5117cacheAfterSize = Math.Max(cacheAfterSize - Math.Floor(logicalSize.Width * sizeAfterEndViewportEdge / pixelSize.Width), 0);
5129cacheAfterSize = Math.Max(cacheAfterSize - pixelSize.Width, 0);
5133cacheAfterSize = Math.Max(cacheAfterSize - logicalSize.Width, 0);
5162viewport.Height = Math.Max(viewport.Height - sizeAfterStartViewportEdge, 0);
5166cacheBeforeSize = Math.Max(cacheBeforeSize - sizeBeforeStartViewportEdge, 0);
5170cacheBeforeSize = Math.Max(cacheBeforeSize - Math.Floor(logicalSize.Height * sizeBeforeStartViewportEdge / pixelSize.Height), 0);
5197viewport.Height = Math.Max(0, parentViewport.Height - pixelSize.Height);
5212cacheAfterSize = Math.Max(cacheAfterSize - sizeAfterEndViewportEdge, 0);
5216cacheAfterSize = Math.Max(cacheAfterSize - Math.Floor(logicalSize.Height * sizeAfterEndViewportEdge / pixelSize.Height), 0);
5228cacheAfterSize = Math.Max(cacheAfterSize - pixelSize.Height, 0);
5232cacheAfterSize = Math.Max(cacheAfterSize - logicalSize.Height, 0);
5297cacheBeforeSize = Math.Max(0, cacheBeforeSize - parentViewport.X);
5302viewport.Width = Math.Max(0, viewport.Width + viewport.X);
5322cacheBeforeSize = Math.Max(0, cacheBeforeSize - inset.Right);
5326cacheBeforeSize = Math.Max(0, cacheBeforeSize - 1);
5341viewport.Width = Math.Max(0, viewport.Width - inset.Left);
5352cacheAfterSize = Math.Max(0, cacheAfterSize - (inset.Left - viewport.Width));
5369cacheAfterSize = Math.Max(0, cacheAfterSize - inset.Left);
5373cacheAfterSize = Math.Max(0, cacheAfterSize - 1);
5400cacheBeforeSize = Math.Max(0, cacheBeforeSize - parentViewport.Y);
5405viewport.Height = Math.Max(0, viewport.Height + viewport.Y);
5425cacheBeforeSize = Math.Max(0, cacheBeforeSize - inset.Bottom);
5429cacheBeforeSize = Math.Max(0, cacheBeforeSize - 1);
5444viewport.Height = Math.Max(0, viewport.Height - inset.Top);
5455cacheAfterSize = Math.Max(0, cacheAfterSize - (inset.Top - viewport.Height));
5472cacheAfterSize = Math.Max(0, cacheAfterSize - inset.Top);
5476cacheAfterSize = Math.Max(0, cacheAfterSize - 1);
5532double spanBeforeViewport = Math.Max(isHorizontal ? viewport.X : viewport.Y, 0.0);
5544firstItemInViewportIndex = (int)Math.Floor(spanBeforeViewport / childSize);
6520double eps = (Math.Abs(value1) + Math.Abs(value2)) * Tolerance;
6701childViewport.X = Math.Min(childViewport.X, 0) -
6704childViewport.Width = Math.Max(childViewport.Width - stackPixelSizeInViewport.Width, 0.0);
6709childViewport.Width = Math.Max(childViewport.Width - stackPixelSizeInViewport.Width, 0.0);
6717Math.Max(parentCacheSize.CacheBeforeViewport - stackLogicalSizeInCacheBeforeViewport.Width, 0.0),
6720Math.Max(parentCacheSize.CacheAfterViewport - stackLogicalSizeInCacheAfterViewport.Width, 0.0));
6728Math.Max(parentCacheSize.CacheBeforeViewport - stackPixelSizeInCacheBeforeViewport.Width, 0.0),
6731Math.Max(parentCacheSize.CacheAfterViewport - stackPixelSizeInCacheAfterViewport.Width, 0.0));
6746childViewport.Y = Math.Min(childViewport.Y, 0) -
6750childViewport.Height = Math.Max(childViewport.Height - stackPixelSizeInViewport.Height, 0.0);
6755childViewport.Height = Math.Max(childViewport.Height - stackPixelSizeInViewport.Height, 0.0);
6763Math.Max(parentCacheSize.CacheBeforeViewport - stackLogicalSizeInCacheBeforeViewport.Height, 0.0),
6766Math.Max(parentCacheSize.CacheAfterViewport - stackLogicalSizeInCacheAfterViewport.Height, 0.0));
6774Math.Max(parentCacheSize.CacheBeforeViewport - stackPixelSizeInCacheBeforeViewport.Height, 0.0),
6777Math.Max(parentCacheSize.CacheAfterViewport - stackPixelSizeInCacheAfterViewport.Height, 0.0));
6884childLogicalSize.Width = Math.Max(itemDesiredSizes.LogicalSize.Width, logicalHeaderSize.Width);
6889childLogicalSize.Height = Math.Max(itemDesiredSizes.LogicalSize.Height, logicalHeaderSize.Height);
7088Size frontPixelSize = isHorizontal ? new Size(Math.Max(inset.Left,0), childDesiredSize.Height)
7089: new Size(childDesiredSize.Width, Math.Max(inset.Top, 0));
7102Size backPixelSize = isHorizontal ? new Size(Math.Max(inset.Right,0), childDesiredSize.Height)
7103: new Size(childDesiredSize.Width, Math.Max(inset.Bottom,0));
7116adjustedChildViewport.Width = Math.Max(0, adjustedChildViewport.Width - childPixelSizeInViewport.Width);
7122adjustedChildViewport.Height = Math.Max(0, adjustedChildViewport.Height - childPixelSizeInViewport.Height);
7207pixelSizeBeforeViewport = DoubleUtil.LessThan(childViewport.X, childPixelSize.Width) ? Math.Max(childViewport.X, 0.0) : childPixelSize.Width;
7208pixelSizeInViewport = Math.Min(childViewport.Width, childPixelSize.Width - pixelSizeBeforeViewport);
7209pixelSizeAfterViewport = Math.Max(childPixelSize.Width - pixelSizeInViewport - pixelSizeBeforeViewport, 0.0); // Please note that due to rounding errors this subtraction can lead to negative values. Hence the Math.Max call
7254logicalSizeBeforeViewport = Math.Floor(childLogicalSize.Width * pixelSizeBeforeViewport / childPixelSize.Width);
7255logicalSizeAfterViewport = Math.Floor(childLogicalSize.Width * pixelSizeAfterViewport / childPixelSize.Width);
7263double childPixelHeightInViewport = Math.Min(childViewport.Height, childPixelSize.Height - Math.Max(childViewport.Y, 0.0));
7266childPixelSizeInViewport.Height = Math.Max(childPixelSizeInViewport.Height, childPixelHeightInViewport);
7268childPixelSizeInCacheBeforeViewport.Height = Math.Max(childPixelSizeInCacheBeforeViewport.Height, childPixelHeightInViewport);
7270childPixelSizeInCacheAfterViewport.Height = Math.Max(childPixelSizeInCacheAfterViewport.Height, childPixelHeightInViewport);
7273childLogicalSizeInViewport.Height = Math.Max(childLogicalSizeInViewport.Height, childLogicalSize.Height);
7275childLogicalSizeInCacheBeforeViewport.Height = Math.Max(childLogicalSizeInCacheBeforeViewport.Height, childLogicalSize.Height);
7277childLogicalSizeInCacheAfterViewport.Height = Math.Max(childLogicalSizeInCacheAfterViewport.Height, childLogicalSize.Height);
7299pixelSizeBeforeViewport = DoubleUtil.LessThan(childViewport.Y, childPixelSize.Height) ? Math.Max(childViewport.Y, 0.0) : childPixelSize.Height;
7300pixelSizeInViewport = Math.Min(childViewport.Height, childPixelSize.Height - pixelSizeBeforeViewport);
7301pixelSizeAfterViewport = Math.Max(childPixelSize.Height - pixelSizeInViewport - pixelSizeBeforeViewport, 0.0); // Please note that due to rounding errors this subtraction can lead to negative values. Hence the Math.Max call
7346logicalSizeBeforeViewport = Math.Floor(childLogicalSize.Height * pixelSizeBeforeViewport / childPixelSize.Height);
7347logicalSizeAfterViewport = Math.Floor(childLogicalSize.Height * pixelSizeAfterViewport / childPixelSize.Height);
7355double childPixelWidthInViewport = Math.Min(childViewport.Width, childPixelSize.Width - Math.Max(childViewport.X, 0.0));
7358childPixelSizeInViewport.Width = Math.Max(childPixelSizeInViewport.Width, childPixelWidthInViewport);
7360childPixelSizeInCacheBeforeViewport.Width = Math.Max(childPixelSizeInCacheBeforeViewport.Width, childPixelWidthInViewport);
7362childPixelSizeInCacheAfterViewport.Width = Math.Max(childPixelSizeInCacheAfterViewport.Width, childPixelWidthInViewport);
7365childLogicalSizeInViewport.Width = Math.Max(childLogicalSizeInViewport.Width, childLogicalSize.Width);
7367childLogicalSizeInCacheBeforeViewport.Width = Math.Max(childLogicalSizeInCacheBeforeViewport.Width, childLogicalSize.Width);
7369childLogicalSizeInCacheAfterViewport.Width = Math.Max(childLogicalSizeInCacheAfterViewport.Width, childLogicalSize.Width);
7412sz1.Height = Math.Max(sz1.Height, sz2.Height);
7417sz1.Width = Math.Max(sz1.Width, sz2.Width);
7467childSize = new Size(Math.Max(headerDesiredSizes.PixelSize.Width, itemDesiredSizes.PixelSize.Width),
7472childSize = new Size(Math.Max(headerDesiredSizes.LogicalSize.Width, itemDesiredSizes.LogicalSize.Width),
7556uniformOrAverageContainerSize = Math.Round(sumOfContainerSizes / numContainerSizes);
7640Math.Max(1, itemDesiredSizes.LogicalSize.Height))
7641: new Size(Math.Max(1, itemDesiredSizes.LogicalSize.Width),
7782Math.Max(uniformOrAverageContainerPixelSize, dpiScale), // don't round down to 0
7792uniformOrAverageContainerSize = Math.Round(sumOfContainerSizes / numContainerSizes);
8455rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height);
8480previousChildSize.Width = Math.Max(previousChildSize.Width, pixelHeaderSize.Width);
8487rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width);
8512previousChildSize.Height = Math.Max(previousChildSize.Height, pixelHeaderSize.Height);
8542rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height);
8548rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width);
8586rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height);
8639rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width);
9516return Math.Max(0, _firstItemInExtendedViewportIndex);
9524return Math.Min(ItemCount, _firstItemInExtendedViewportIndex + _actualItemsInExtendedViewportCount);
9642_scrollData._maxDesiredSize.Height = Math.Max(_scrollData._maxDesiredSize.Height, stackPixelSize.Height);
9669_scrollData._maxDesiredSize.Width = Math.Max(_scrollData._maxDesiredSize.Width, stackPixelSize.Width);
9695Math.Min(stackPixelSize.Width, constraint.Width) : constraint.Width;
9700Math.Min(stackPixelSize.Height, constraint.Height) : constraint.Height;
9966double proposedViewportSize = Math.Floor(viewport.Width / approxSizeOfLogicalUnit);
10059if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.X)/extentSize.Width, Math.Floor(_scrollData._offset.X)/_scrollData._extent.Width))
10062viewportOffset.X = Math.Floor((extentSize.Width * Math.Floor(_scrollData._offset.X)) / _scrollData._extent.Width);
10183double proposedViewportSize = Math.Floor(viewport.Height / approxSizeOfLogicalUnit);
10276if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.Y)/extentSize.Height, Math.Floor(_scrollData._offset.Y)/_scrollData._extent.Height))
10279viewportOffset.Y = Math.Floor((extentSize.Height * Math.Floor(_scrollData._offset.Y)) / _scrollData._extent.Height);
10491_scrollData._maxDesiredSize.Height = Math.Max(_scrollData._maxDesiredSize.Height, stackPixelSize.Height);
10518_scrollData._maxDesiredSize.Width = Math.Max(_scrollData._maxDesiredSize.Width, stackPixelSize.Width);
10544Math.Min(stackPixelSize.Width, constraint.Width) : constraint.Width;
10549Math.Min(stackPixelSize.Height, constraint.Height) : constraint.Height;
10645lastPageSafeOffset = lastPageSafeOffset.HasValue ? Math.Min(computedViewportOffset.X, (double)lastPageSafeOffset) : computedViewportOffset.X;
10648double proposedViewportSize = Math.Floor(viewport.Width / approxSizeOfLogicalUnit);
10730if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.X)/extentSize.Width, Math.Floor(_scrollData._offset.X)/_scrollData._extent.Width))
10733viewportOffset.X = Math.Floor((extentSize.Width * Math.Floor(_scrollData._offset.X)) / _scrollData._extent.Width);
10776lastPageSafeOffset = lastPageSafeOffset.HasValue ? Math.Min(computedViewportOffset.Y, (double)lastPageSafeOffset) : computedViewportOffset.Y;
10779double proposedViewportSize = Math.Floor(viewport.Height / approxSizeOfLogicalUnit);
10861if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.Y)/extentSize.Height, Math.Floor(_scrollData._offset.Y)/_scrollData._extent.Height))
10864viewportOffset.Y = Math.Floor((extentSize.Height * Math.Floor(_scrollData._offset.Y)) / _scrollData._extent.Height);
11162double visibleStart = Math.Max(start, 0);
11163double visibleEnd = Math.Max(Math.Min(end, viewportSize), visibleStart);
11208else if (childIndex > firstChildInView + Math.Max(viewportSize - 1, 0))
11254maxChildLength = Math.Max(maxChildLength, childSize.Height);
11258maxChildLength = Math.Max(maxChildLength, childSize.Width);
11850else if (DoubleUtil.GreaterThan(Math.Abs(newOffset - oldOffset), _viewport.Width))
11866else if (DoubleUtil.GreaterThan(Math.Abs(newOffset - oldOffset), _viewport.Height))
System\Windows\Documents\TextStore.cs (12)
985milPointTopLeft = new Point(Math.Min(rectPrev.Left, rectCur.Left), Math.Min(rectPrev.Top, rectCur.Top));
986milPointBottomRight = new Point(Math.Max(rectPrev.Left, rectCur.Left), Math.Max(rectPrev.Bottom, rectCur.Bottom));
2443runCount = TextPointerBase.GetTextWithLimit(navigator, LogicalDirection.Forward, text, charsCopied, Math.Min(cchReq, text.Length - charsCopied), limit);
2846double radSin = Math.Asin(tf.M12 / Math.Sqrt((tf.M11 * tf.M11) + (tf.M12 * tf.M12)));
2847double radCos = Math.Acos(tf.M11 / Math.Sqrt((tf.M11 * tf.M11) + (tf.M12 * tf.M12)));
2849double angleCos = Math.Round((radCos * 180) / Math.PI, 0);
3809int extraCharsAllowed = Math.Max(0, this.TextEditor.MaxLength - currentLength);
System\Windows\FrameworkElement.cs (59)
4045maxHeight = Math.Max(Math.Min(height, maxHeight), minHeight);
4048minHeight = Math.Max(Math.Min(maxHeight, height), minHeight);
4055maxWidth = Math.Max(Math.Min(width, maxWidth), minWidth);
4058minWidth = Math.Max(Math.Min(maxWidth, width), minWidth);
4160Double yCoverD = (yConstrInfinite ? Double.PositiveInfinity : Math.Abs(yConstr/d));
4161Double xCoverA = (xConstrInfinite ? Double.PositiveInfinity : Math.Abs(xConstr/a));
4181h = Math.Min(0.5*Math.Abs(xConstr/c), yCoverD);
4192w = Math.Min( 0.5*Math.Abs(yConstr/b), xCoverA);
4200Double yCoverB = Math.Abs(yConstr/b);
4201Double xCoverC = Math.Abs(xConstr/c);
4221h = Math.Min(0.5*Math.Abs(yConstr/d), xCoverC);
4232w = Math.Min( 0.5*Math.Abs(xConstr/a), yCoverB);
4238Double xCoverA = Math.Abs(xConstr / a); // w-intercept of x-constraint line.
4239Double xCoverC = Math.Abs(xConstr / c); // h-intercept of x-constraint line.
4241Double yCoverB = Math.Abs(yConstr / b); // w-intercept of y-constraint line.
4242Double yCoverD = Math.Abs(yConstr / d); // h-intercept of y-constraint line.
4249w = Math.Min(yCoverB, xCoverA) * 0.5;
4250h = Math.Min(xCoverC, yCoverD) * 0.5;
4267Double expandFactor = Math.Min(xConstr / childBoundsTr.Width,
4326Math.Max(availableSize.Width - marginWidth, 0),
4327Math.Max(availableSize.Height - marginHeight, 0));
4375frameworkAvailableSize.Width = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth));
4376frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight));
4389Math.Max(desiredSize.Width, mm.minWidth),
4390Math.Max(desiredSize.Height, mm.minHeight));
4454ltd?.TransformedUnroundedDS = new Size(Math.Max(0, clippedDesiredWidth), Math.Max(0, clippedDesiredHeight));
4500return new Size(Math.Max(0, clippedDesiredWidth), Math.Max(0, clippedDesiredHeight));
4562arrangeSize.Width = Math.Max(0, arrangeSize.Width - marginWidth);
4563arrangeSize.Height = Math.Max(0, arrangeSize.Height - marginHeight);
4572transformedUnroundedDS.Width = Math.Max(0, transformedUnroundedDS.Width - marginWidth);
4573transformedUnroundedDS.Height = Math.Max(0, transformedUnroundedDS.Height- marginHeight);
4582unclippedDesiredSize = new Size(Math.Max(0, this.DesiredSize.Width - marginWidth),
4583Math.Max(0, this.DesiredSize.Height - marginHeight));
4588unclippedDesiredSize.Width = Math.Max(transformedUnroundedDS.Width, unclippedDesiredSize.Width);
4589unclippedDesiredSize.Height = Math.Max(transformedUnroundedDS.Height, unclippedDesiredSize.Height);
4676double effectiveMaxWidth = Math.Max(unclippedDesiredSize.Width, mm.maxWidth);
4683double effectiveMaxHeight = Math.Max(unclippedDesiredSize.Height, mm.maxHeight);
4714Size clippedInkSize = new Size(Math.Min(innerInkSize.Width, mm.maxWidth),
4715Math.Min(innerInkSize.Height, mm.maxHeight));
4747Size clientSize = new Size(Math.Max(0, finalRect.Width - marginWidth),
4748Math.Max(0, finalRect.Height - marginHeight));
4899inkSize.Width = Math.Min(inkSize.Width, mm.maxWidth);
4900inkSize.Height = Math.Min(inkSize.Height, mm.maxHeight);
4917Size clippingSize = new Size(Math.Max(0, layoutSlotSize.Width - marginWidth),
4918Math.Max(0, layoutSlotSize.Height - marginHeight));
5236inkSize.Width = Math.Min(inkSize.Width, mm.maxWidth);
5237inkSize.Height = Math.Min(inkSize.Height, mm.maxHeight);
System\Windows\Shell\WindowChromeWorker.cs (23)
804double shortestDimension = Math.Min(windowSize.Width, windowSize.Height);
807topLeftRadius = Math.Min(topLeftRadius, shortestDimension / 2);
823topRightRadius = Math.Min(topRightRadius, shortestDimension / 2);
831bottomLeftRadius = Math.Min(bottomLeftRadius, shortestDimension / 2);
839bottomRightRadius = Math.Min(bottomRightRadius, shortestDimension / 2);
866(int)Math.Floor(region.Left),
867(int)Math.Floor(region.Top),
868(int)Math.Ceiling(region.Right),
869(int)Math.Ceiling(region.Bottom));
874(int)Math.Floor(region.Left),
875(int)Math.Floor(region.Top),
876(int)Math.Ceiling(region.Right) + 1,
877(int)Math.Ceiling(region.Bottom) + 1,
878(int)Math.Ceiling(radius),
879(int)Math.Ceiling(radius));
967deviceGlassThickness.Top = Math.Max(0, deviceGlassThickness.Top);
972deviceGlassThickness.Left = Math.Max(0, deviceGlassThickness.Left);
977deviceGlassThickness.Bottom = Math.Max(0, deviceGlassThickness.Bottom);
982deviceGlassThickness.Right = Math.Max(0, deviceGlassThickness.Right);
989cxLeftWidth = (int)Math.Ceiling(deviceGlassThickness.Left),
990cxRightWidth = (int)Math.Ceiling(deviceGlassThickness.Right),
991cyTopHeight = (int)Math.Ceiling(deviceGlassThickness.Top),
992cyBottomHeight = (int)Math.Ceiling(deviceGlassThickness.Bottom),
System\Windows\Window.cs (30)
1807frameworkAvailableSize.Width = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth));
1808frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight));
1815Math.Max(desiredSize.Width, mm.minWidth),
1816Math.Max(desiredSize.Height, mm.minHeight));
1837arrangeBounds.Width = Math.Max(mm.minWidth, Math.Min(arrangeBounds.Width, mm.maxWidth));
1838arrangeBounds.Height = Math.Max(mm.minHeight, Math.Min(arrangeBounds.Height, mm.maxHeight));
1873Width = Math.Max(0.0, arrangeBounds.Width - frameSize.Width),
1874Height = Math.Max(0.0, arrangeBounds.Height - frameSize.Height)
3406Width = ((constraint.Width == Double.PositiveInfinity) ? Double.PositiveInfinity : Math.Max(0.0, (constraint.Width - frameSize.Width))),
3407Height = ((constraint.Height == Double.PositiveInfinity) ? Double.PositiveInfinity : Math.Max(0.0, (constraint.Height - frameSize.Height)))
3452maxWidthDeviceUnits = Math.Max(_trackMaxWidthDeviceUnits, _windowMaxWidthDeviceUnits);
3453maxHeightDeviceUnits = Math.Max(_trackMaxHeightDeviceUnits, _windowMaxHeightDeviceUnits);
3462mm.minWidth = Math.Max(this.MinWidth, minSizeLogicalUnits.X);
3467mm.maxWidth = Math.Min(MinWidth, maxSizeLogicalUnits.X);
3473mm.maxWidth = Math.Min(MaxWidth, maxSizeLogicalUnits.X);
3484mm.minHeight = Math.Max(this.MinHeight, minSizeLogicalUnits.Y);
3489mm.maxHeight = Math.Min(this.MinHeight, maxSizeLogicalUnits.Y);
3495mm.maxHeight = Math.Min(MaxHeight, maxSizeLogicalUnits.Y);
3846leftDeviceUnits = Math.Min(leftDeviceUnits, workAreaRectDeviceUnits.right - currentSizeDeviceUnits.Width);
3847leftDeviceUnits = Math.Max(leftDeviceUnits, workAreaRectDeviceUnits.left);
3848topDeviceUnits = Math.Min(topDeviceUnits, workAreaRectDeviceUnits.bottom - currentSizeDeviceUnits.Height);
3849topDeviceUnits = Math.Max(topDeviceUnits, workAreaRectDeviceUnits.top);
4705_windowMaxWidthDeviceUnits = Math.Max(_windowMaxWidthDeviceUnits, windowSize.X);
4706_windowMaxHeightDeviceUnits = Math.Max(_windowMaxHeightDeviceUnits, windowSize.Y);
7591return new Size(Math.Max(0.0, pt.X), Math.Max(0.0, pt.Y));
PresentationFramework.Aero (21)
PresentationFramework.Aero2 (21)
PresentationFramework.AeroLite (14)
PresentationFramework.Classic (23)
Microsoft\Windows\Themes\ClassicBorderDecorator.cs (11)
235float min = Math.Min(rgbColor.Red, Math.Min(rgbColor.Green, rgbColor.Blue));
236float max = Math.Max(rgbColor.Red, Math.Max(rgbColor.Green, rgbColor.Blue));
268saturation = Math.Max(0.0f, Math.Min(saturation, 1.0f));
323float hue = (float)((hlsColor.Hue - Math.Floor(hlsColor.Hue)) * 6);
601Math.Max(0.0, rt.Width - thick.Left - thick.Right),
602Math.Max(0.0, rt.Height - thick.Top - thick.Bottom));
690desired = new Size(Math.Min(borderSize.Width, availableSize.Width), Math.Min(borderSize.Height, availableSize.Height));
PresentationFramework.Luna (27)
PresentationFramework.Royale (26)
PresentationUI (6)
Publishers.AppHost (2)
ReachFramework (93)
AlphaFlattener\BrushProxy.cs (32)
512rb.RadiusX = Math.Abs(rb.RadiusX * bounds.Width);
513rb.RadiusY = Math.Abs(rb.RadiusY * bounds.Height);
1910double length = Math.Sqrt(dx * dx + dy * dy);
1924stopDistance = Math.Max(b.RadiusX, b.RadiusY) * (second.Offset - first.Offset);
1942int stopCount = (int)Math.Ceiling(-6.297427 + 4.591693 * Math.Log(stopDistance));
2281double height = Math.Abs(start.Y - end.Y) * multiplier;
2290double width = Math.Abs(start.X - end.X) * multiplier;
2572if (Utility.AreClose(new Vector(Math.Abs(rbA.RadiusX), Math.Abs(rbA.RadiusY)) * rbA.Transform.Value,
2573new Vector(Math.Abs(rbB.RadiusX), Math.Abs(rbB.RadiusY)) * rbB.Transform.Value))
3739min = Math.Min(min, offset);
3740max = Math.Max(max, offset);
3866return Math.Sqrt(sum);
3895return (int)Math.Ceiling(Math.Max(5, step)); // At least five. Radials look bad with less steps.
3944if (Math.Abs(di) < Double.Epsilon)
4038double right = Math.Ceiling(_bounds.Right / _bandDelta);
4039double left = Math.Floor(_bounds.Left / _bandDelta);
4138double rotateAngle = Math.Atan2(-gradientVector.Y, gradientVector.X) * 180.0 / Math.PI;
4183_rx = Math.Abs(b.RadiusX);
4184_ry = Math.Abs(b.RadiusY);
4265double right = Math.Ceiling(maxt * _bandSteps);
4266double left = Math.Floor(mint * _bandSteps);
4383double root = Math.Sqrt(B4AC);
4392maxt = Math.Max(maxt, one);
4393mint = Math.Min(mint, one);
4400maxt = Math.Max(maxt, two);
4401mint = Math.Min(mint, two);
4426double len = Math.Sqrt(dx * dx + dy * dy);
Serialization\VisualSerializer.cs (10)
467scalex = Math.Min(dstwidth / srcwidth, dstheight / srcheight);
472scalex = Math.Max(dstwidth / srcwidth, dstheight / srcheight);
749WriteAttr("RadiusX", Math.Abs(rb.RadiusX * bounds.Width));
750WriteAttr("RadiusY", Math.Abs(rb.RadiusY * bounds.Height));
916WriteAttr("StrokeThickness", Math.Abs(pen.Thickness));
926WriteAttr("StrokeMiterLimit", Math.Max(1.0, pen.MiterLimit));
948dashes.Add(Math.Abs(d));
2258WriteAttr("Opacity", Math.Min(Math.Max( opacity, 0.0),1.0));
2321SetCoordinateFormat(Math.Min(Utility.GetScaleX(mat), Utility.GetScaleY(mat)));
Roslyn.Diagnostics.Analyzers (103)
src\roslyn\src\Dependencies\Collections\Segmented\SegmentedArray.cs (10)
496var currentSegmentLength = Math.Min(remainingInSegment, _length);
505var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed);
600var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
648var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed);
738_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
745_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
787_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length));
794_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
574LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation),
576LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation),
577LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column),
586LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces),
587LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0),
594var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1));
596return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines;
745return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
Roslyn.Diagnostics.CSharp.Analyzers (7)
Roslyn.Diagnostics.VisualBasic.Analyzers (13)
src\roslyn\src\Workspaces\SharedUtilitiesAndExtensions\Compiler\VisualBasic\Formatting\Rules\ElasticTriviaFormattingRule.vb (6)
221Return CreateAdjustNewLinesOperation(Math.Max(If(operation Is Nothing, 1, operation.Line), 0), AdjustNewLinesOption.PreserveLines)
338Return Math.Max(lines, 0)
351Return Math.Max(If(lines > afterCommentWithBlank, lines, afterCommentWithBlank), 0)
355Return Math.Max(totalLines - blankLines + leadingBlankLines, 0)
358Return Math.Max(totalLines, 0)
361Return Math.Max(lines, 0)
ScenarioTests.Common.Tests (1)
sdk-tasks (1)
Stress.ApiService (7)
System.Collections (5)
System.Collections.Concurrent (5)
System.Collections.Immutable (13)
System.CommandLine (3)
System.ComponentModel.TypeConverter (6)
System.Console (3)
System.Data.Common (88)
System\Data\SQLTypes\SQLDecimal.cs (26)
414precision = Math.Max(precision, _bScale);
680double dInt = Math.Floor(dVal);
687dVal = Math.Floor(dInt / s_DUINT_BASE);
693dVal = Math.Floor(dInt / s_DUINT_BASE);
700dVal = Math.Floor(dInt / s_DUINT_BASE);
707dVal = Math.Floor(dInt / s_DUINT_BASE);
766dFrac -= Math.Floor(dFrac);
1138dRet /= System.Math.Pow(10.0, _bScale);
1258ResInteger = Math.Max(x._bPrec - MyScale, y._bPrec - OpScale);
1262ResScale = Math.Max(MyScale, OpScale);
1268ResPrec = Math.Min(MaxPrecision, ResPrec);
1472ResScale = Math.Min((ResPrec - ResInteger), ResScale);
1474ResScale = Math.Max(ResScale, Math.Min(ActualScale, s_cNumeDivScaleMin));
1695ResScale = Math.Max(x._bScale + y._bPrec + 1, s_cNumeDivScaleMin);
1698MinScale = Math.Min(ResScale, s_cNumeDivScaleMin);
1700ResInteger = Math.Min(ResInteger, s_NUMERIC_MAX_PRECISION);
1707ResScale = Math.Min((ResPrec - ResInteger), ResScale);
1708ResScale = Math.Max(ResScale, MinScale);
2304bNewPrec = (byte)(Math.Min(s_NUMERIC_MAX_PRECISION, Math.Max(1, lAdjust + _bPrec)));
3175lPosition = Math.Min(s_NUMERIC_MAX_PRECISION, lPosition);
3182lPosition = Math.Max(-s_NUMERIC_MAX_PRECISION, lPosition);
3193int lAdjust = Math.Abs(lPosition - n._bScale); // Precision adjustment
3232lAdjust = Math.Abs(lPosition - n._bScale);
3268n = new SqlDecimal(Math.Pow(dBaseNum, exp));
System.Data.Odbc (28)
System\Data\Odbc\OdbcDataReader.cs (12)
571int nValues = Math.Min(values.Length, FieldCount);
972string strdata = buffer.PtrToStringUni(0, Math.Min(lengthOrIndicator, cbMaxData) / 2);
1013cbActual = Math.Min(lengthOrIndicator, cbMaxData);
1185int lengthOfCopy = Math.Min(lengthFromDataIndex, length);
1188lengthOfCopy = Math.Min(lengthOfCopy, buffer.Length - bufferIndex);
1308length = Math.Min(length, buffer.Length - bufferIndex);
1370cbReadMax = (int)Math.Min(cbLength, internalNativeBuffer.Length - 4);
1379cbReadMax = (int)Math.Min(cbLength, internalNativeBuffer.Length - 2);
1476Buffer.ReadBytes(0, rgBytes, cbOffset, Math.Min(cbActual, cbBufferLen));
1489buffer.ReadBytes(0, rgBytes, cbOffset, Math.Min(cbActual, cbBufferLen));
2277row[columnSize] = unchecked((int)Math.Min(Math.Max(int.MinValue, _metadata![i].size.ToInt64()), int.MaxValue));
System.Data.OleDb (22)
ColumnBinding.cs (11)
188return Math.Max(length, 0);
251_valueBindingOffset = Math.Max(offset, 0);
256_valueBindingSize = Math.Max(size, 0);
694LengthValue(((0 < ValueBindingSize) ? Math.Min(ValueBindingSize, length) : length));
741LengthValue(((0 < ValueBindingSize) ? Math.Min(ValueBindingSize, length) : length) * 2); /* charcount->bytecount*/
760LengthValue(((0 < ValueBindingSize) ? Math.Min(ValueBindingSize, length) : length) * 2); /* charcount->bytecount*/
777int byteCount = Math.Min(LengthValue(), ColumnBindingMaxLen);
786int bytecount = ((ValueBindingOffset < value.Length) ? Math.Min(value.Length - ValueBindingOffset, ColumnBindingMaxLen) : 0);
1200int byteCount = Math.Min(LengthValue(), ColumnBindingMaxLen - 2);
1208int charCount = ((ValueBindingOffset < value.Length) ? Math.Min(value.Length - ValueBindingOffset, (ColumnBindingMaxLen - 2) / 2) : 0);
1223int charCount = ((ValueBindingOffset < value.Length) ? Math.Min(value.Length - ValueBindingOffset, (ColumnBindingMaxLen - 2) / 2) : 0);
System.Diagnostics.DiagnosticSource (15)
System.Diagnostics.EventLog (1)
System.Diagnostics.Process (9)
System.Diagnostics.TextWriterTraceListener (1)
System.DirectoryServices.Protocols (1)
System.Drawing.Primitives (32)
System\Drawing\Rectangle.cs (16)
182(int)Math.Ceiling(value.X),
183(int)Math.Ceiling(value.Y),
184(int)Math.Ceiling(value.Width),
185(int)Math.Ceiling(value.Height));
212(int)Math.Round(value.X),
213(int)Math.Round(value.Y),
214(int)Math.Round(value.Width),
215(int)Math.Round(value.Height));
290int x1 = Math.Max(a.X, b.X);
291int x2 = Math.Min(a.X + a.Width, b.X + b.Width);
292int y1 = Math.Max(a.Y, b.Y);
293int y2 = Math.Min(a.Y + a.Height, b.Y + b.Height);
315int x1 = Math.Min(a.X, b.X);
316int x2 = Math.Max(a.X + a.Width, b.X + b.Width);
317int y1 = Math.Min(a.Y, b.Y);
318int y2 = Math.Max(a.Y + a.Height, b.Y + b.Height);
System.Formats.Asn1 (13)
System.Formats.Nrbf (3)
System.Formats.Tar (19)
System.IO.Compression (24)
System.IO.FileSystem.AccessControl (2)
System.IO.FileSystem.Watcher (2)
System.IO.Hashing (7)
System.IO.Pipelines (9)
System.IO.Ports (5)
System.Linq (22)
System.Linq.AsyncEnumerable (7)
System.Linq.Expressions (8)
System.Linq.Parallel (7)
System.Management (1)
System.Memory (5)
System.Memory.Data (1)
System.Net.Http (55)
System.Net.Http.WinHttpHandler (2)
System.Net.HttpListener (10)
System.Net.Mail (10)
System.Net.NameResolution (2)
System.Net.NetworkInformation (1)
System.Net.Ping (4)
System.Net.Primitives (7)
System.Net.Quic (7)
System.Net.Requests (4)
System.Net.Security (12)
System.Net.ServerSentEvents (8)
System.Net.Sockets (5)
System.Net.WebSockets (8)
System.Numerics.Tensors (58)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IAggregationOperator.cs (6)
264(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector128<T>.Count);
446(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector256<T>.Count);
628(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector512<T>.Count);
1403(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector128<T>.Count);
1610(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector256<T>.Count);
1817(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector512<T>.Count);
System\Numerics\Tensors\netcore\Tensor.cs (27)
550span[i] = T.CreateChecked(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2));
570span[j] = T.CreateChecked(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2));
581enumerator.Current = T.CreateChecked(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2));
1816nint copyLength = Math.Min(tensor.FlattenedLength, newSize);
1872nint copyLength = Math.Min(tensor.FlattenedLength, destinationLength);
1920nint copyLength = Math.Min(source.FlattenedLength, destination.FlattenedLength);
1961int count = (int)Math.Min(destination.FlattenedLength - cleared, int.MaxValue);
2125int count = (int)Math.Min(innerLength == 1 ? axisLength / 2 : innerLength,
2126Math.Max(1, MaxBufferBytes / Unsafe.SizeOf<T>()));
2135int length = (int)Math.Min(axisLength / 2 - left, buffer.Length);
2152int length = (int)Math.Min(innerLength - offset, buffer.Length);
2178int count = (int)Math.Min(tensor.FlattenedLength - offset, int.MaxValue);
2235int count = (int)Math.Min(destination.FlattenedLength - offset, int.MaxValue);
2243span[i] = T.CreateChecked(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2));
2350int count = (int)Math.Min(tensor.FlattenedLength - offset, int.MaxValue);
System\Numerics\Tensors\netcore\TensorOperation.cs (24)
92int count = (int)Math.Min(copyLength - copied, int.MaxValue);
151int count = (int)Math.Min(slice.FlattenedLength, copyLength - copied);
195int count = (int)Math.Min(offset, int.MaxValue);
218int count = (int)Math.Min(offset, int.MaxValue);
246int count = (int)Math.Min(Math.Min(sourceSliceLength - sourceOffset, destinationSliceLength - targetOffset), copyLength - copied);
285int count = (int)Math.Min(Math.Min(sourceOffset, destinationSliceLength - targetOffset), int.MaxValue);
324int count = (int)Math.Min(Math.Min(sliceLength - offset, copyLength - copied), int.MaxValue);
343int count = (int)Math.Min(destination.FlattenedLength - offset, int.MaxValue);
355int count = (int)Math.Min(destination.FlattenedLength - offset, int.MaxValue);
367int count = (int)Math.Min(destination.FlattenedLength - offset, int.MaxValue);
378int count = (int)Math.Min(destination.FlattenedLength - offset, int.MaxValue);
393int count = (int)Math.Min(remaining, maximumChunkLength);
503int length = (int)Math.Min(flattenedLength - offset, maximumChunkLength);
526int length = Math.Min(values.Length - start, maximumChunkLength);
553int bufferLength = (int)Math.Min(flattenedLength, Math.Min(maximumChunkLength, 1024));
561int length = (int)Math.Min(flattenedLength - offset, bufferLength);
616int count = (int)Math.Min(x.FlattenedLength - offset, int.MaxValue);
757int rank = Math.Max(x.Rank, y.Rank);
867int count = (int)Math.Min(destination.FlattenedLength - offset, int.MaxValue);
1499int maxRank = Math.Max(xLengths.Length, yLengths.Length);
System.Private.CoreLib (649)
src\runtime\src\libraries\Common\src\System\Number.Formatting.Common.cs (16)
284(value, uint remainder) = Math.DivRem(value, 100);
312(value, remainder) = Math.DivRem(value, 100);
318(value, remainder) = Math.DivRem(value, 10);
718digits = digits.Slice(0, Math.Min(number.DigitsCount, digits.Length));
735ReadOnlySpan<byte> adjustDigits = digits.Slice(0, Math.Min(adjust, digits.Length));
994dig = dig.Slice(0, Math.Min(number.DigitsCount, dig.Length));
1032ReadOnlySpan<byte> intDigits = dig.Slice(0, Math.Min(digPos, dig.Length));
1039int digitsInGroup = (groupSize > 0) ? Math.Min(groupSize, remainingDigits) : remainingDigits;
1082int actualDigits = Math.Min(digPos, dig.Length);
1106int zeroes = Math.Min(-digPos, nMaxDigits);
1115int decActual = Math.Min(nMaxDigits, remainingDig);
1201dig = dig.Slice(0, Math.Min(number.DigitsCount, dig.Length));
1215foreach (byte b in dig.Slice(1, Math.Min(nMaxDigits - 1, dig.Length - 1)))
1249int digitCount = Math.Max(minDigits, FormattingHelpers.CountDigits((uint)value));
1273dig = dig.Slice(0, Math.Min(number.DigitsCount, dig.Length));
1278int intCount = Math.Min(digPos, dig.Length);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Byte.cs (4)
274public static (byte Quotient, byte Remainder) DivRem(byte left, byte right) => Math.DivRem(left, right);
521public static byte Clamp(byte value, byte min, byte max) => Math.Clamp(value, min, max);
527public static byte Max(byte x, byte y) => Math.Max(x, y);
533public static byte Min(byte x, byte y) => Math.Min(x, y);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\BitArray.cs (7)
120(uint index, uint extraBits) = Math.DivRem((uint)_bitLength, BitsPerInt32);
280(uint byteIndex, uint bitOffset) = Math.DivRem(i, BitsPerByte);
395(uint byteIndex, uint bitOffset) = Math.DivRem((uint)index, BitsPerByte);
414(uint byteIndex, uint bitOffset) = Math.DivRem((uint)index, BitsPerByte);
618(int fromIndex, int shiftCount) = Math.DivRem(count, 32);
681(lengthToClear, int shiftCount) = Math.DivRem(count, BitsPerInt32);
915(uint byteIndex, uint extraBits) = Math.DivRem(i, BitsPerByte);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Decimal.DecCalc.cs (44)
168ulong high = Math.BigMul(a, b, out ulong low);
227(div, rem) = Math.DivRem(tmp, den);
232(div, rem) = Math.DivRem(tmp, den);
240(bufNum.Low64, rem) = Math.DivRem(tmp, den);
393(ulong quo64, bufNum.Low64) = Math.DivRem(num, den);
435ulong prod = Math.BigMul(quo, (uint)den); // quo * lo divisor
480uint prod2 = (uint)Math.BigMul(bufDen.Low64, quo, out prod1);
536ulong hi64 = Math.BigMul(bufNum.Low64, power, out ulong low64);
538hi64 = Math.BigMul(bufNum.U2, power) + hi64;
563ulong hi64 = Math.BigMul(bufNum.Low64, power, out ulong low64);
565bufNum.High64 = Math.BigMul(bufNum.U2, power) + hi64;
579bufNum.U2 = (uint)Math.BigMul(bufNum.Low64, power, out ulong low64);
768(quotient, remainder) = Math.DivRem(high, power);
1020low64 = Math.BigMul((uint)low64, UInt32Powers10[scale]);
1024low64 = Math.BigMul((uint)low64, TenToPowerNine);
1033high = (uint)Math.BigMul(low64, power, out low64);
1046tmp64 = Math.BigMul(low64, power, out low64);
1047tmp64 += Math.BigMul(high, power);
1079tmp64 += Math.BigMul(num[cur], power);
1297ulong high = Math.BigMul(pdecIn.Low64, pwr, out ulong low);
1395ulong tmp = Math.BigMul(low64, power, out low64);
1396tmp += Math.BigMul(high, power);
1439ulong low64 = Math.BigMul(d1.Low, d2.Low);
1452(low64, ulong remainder) = Math.DivRem(low64, power);
1470tmp = Math.BigMul(d1.Low, d2.Low64, out ulong low);
1475tmp += Math.BigMul(d1.Low, d2.High);
1490tmp = Math.BigMul(d1.Low64, d2.Low, out ulong low);
1495tmp += Math.BigMul(d2.Low, d1.High);
1525ulong mid64 = Math.BigMul(d1.Low64, d2.Low64, out tmp);
1531ulong hi64 = Math.BigMul(d1.High, d2.High);
1534hi64 += Math.BigMul(d1.Low64, d2.High, out tmp);
1540hi64 += Math.BigMul(d2.Low64, d1.High, out tmp);
1672scale = Math.Min(k, DEC_SCALE_MAX);
1854return Math.ScaleB((double)(ulong)subnormalQuotient, subnormalExponent);
1903return Math.ScaleB((double)keep, exponent);
2006curScale = Math.Min(9, -scale);
2050ulong num = Math.BigMul(remainder, power);
2097curScale = Math.Min(9, -scale);
2159curScale = Math.Min(9, -scale);
2275uint hi32 = (uint)Math.BigMul(d2.Low64, power, out ulong low64);
2382ulong tmp64 = Math.BigMul(head.U0, power);
2387tmp64 += Math.BigMul(buf[i], power);
2477(d.uhi, remainder) = Math.DivRem(n, divisor);
2518(d.uhi, remainder) = Math.DivRem(n, power);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Double.cs (58)
70public const double E = Math.E;
74public const double Pi = Math.PI;
78public const double Tau = Math.Tau;
578public static double Log2(double value) => Math.Log2(value);
632public static double Exp(double x) => Math.Exp(x);
635public static double ExpM1(double x) => Math.Exp(x) - 1;
638public static double Exp2(double x) => Math.Pow(2, x);
641public static double Exp2M1(double x) => Math.Pow(2, x) - 1;
644public static double Exp10(double x) => Math.Pow(10, x);
647public static double Exp10M1(double x) => Math.Pow(10, x) - 1;
655public static double Ceiling(double x) => Math.Ceiling(x);
680public static double Floor(double x) => Math.Floor(x);
684public static double Round(double x) => Math.Round(x);
687public static double Round(double x, int digits) => Math.Round(x, digits);
690public static double Round(double x, MidpointRounding mode) => Math.Round(x, mode);
693public static double Round(double x, int digits, MidpointRounding mode) => Math.Round(x, digits, mode);
697public static double Truncate(double x) => Math.Truncate(x);
800static double IFloatingPointConstants<double>.E => Math.E;
829public static double Atan2(double y, double x) => Math.Atan2(y, x);
835public static double BitDecrement(double x) => Math.BitDecrement(x);
838public static double BitIncrement(double x) => Math.BitIncrement(x);
842public static double FusedMultiplyAdd(double left, double right, double addend) => Math.FusedMultiplyAdd(left, right, addend);
845public static double Ieee754Remainder(double left, double right) => Math.IEEERemainder(left, right);
848public static int ILogB(double x) => Math.ILogB(x);
855public static double ReciprocalEstimate(double x) => Math.ReciprocalEstimate(x);
859public static double ReciprocalSqrtEstimate(double x) => Math.ReciprocalSqrtEstimate(x);
862public static double ScaleB(double x, int n) => Math.ScaleB(x, n);
873public static double Acosh(double x) => Math.Acosh(x);
877public static double Asinh(double x) => Math.Asinh(x);
881public static double Atanh(double x) => Math.Atanh(x);
885public static double Cosh(double x) => Math.Cosh(x);
889public static double Sinh(double x) => Math.Sinh(x);
893public static double Tanh(double x) => Math.Tanh(x);
908public static double Log(double x) => Math.Log(x);
911public static double Log(double x, double newBase) => Math.Log(x, newBase);
914public static double LogP1(double x) => Math.Log(x + 1);
917public static double Log2P1(double x) => Math.Log2(x + 1);
921public static double Log10(double x) => Math.Log10(x);
924public static double Log10P1(double x) => Math.Log10(x + 1);
966Math.ThrowMinMaxException(min, max);
976Math.ThrowMinMaxException(min, max);
982public static double CopySign(double value, double sign) => Math.CopySign(value, sign);
986public static double Max(double x, double y) => Math.Max(x, y);
1024public static double Min(double x, double y) => Math.Min(x, y);
1061public static int Sign(double value) => Math.Sign(value);
1078public static double Abs(double value) => Math.Abs(value);
1191public static double MaxMagnitude(double x, double y) => Math.MaxMagnitude(x, y);
1221public static double MinMagnitude(double x, double y) => Math.MinMagnitude(x, y);
1574public static double Pow(double x, double y) => Math.Pow(x, y);
1582public static double Cbrt(double x) => Math.Cbrt(x);
1866public static double Sqrt(double x) => Math.Sqrt(x);
1898public static double Acos(double x) => Math.Acos(x);
1908public static double Asin(double x) => Math.Asin(x);
1918public static double Atan(double x) => Math.Atan(x);
1928public static double Cos(double x) => Math.Cos(x);
2259public static double Sin(double x) => Math.Sin(x);
2262public static (double Sin, double Cos) SinCos(double x) => Math.SinCos(x);
2467public static double Tan(double x) => Math.Tan(x);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (9)
185int digitCount = Math.Max(minimumLength, FormattingHelpers.CountDigits((uint)value));
479FormatDigits(ref result, hour12, Math.Min(tokenLen, 2));
484FormatDigits(ref result, dateTime.Hour, Math.Min(tokenLen, 2));
489FormatDigits(ref result, dateTime.Minute, Math.Min(tokenLen, 2));
494FormatDigits(ref result, dateTime.Second, Math.Min(tokenLen, 2));
653FormatDigits(ref result, year, Math.Min(tokenLen, 2));
891(int tens, int ones) = Math.DivRem(offset.Hours, 10);
1566(int offsetHours, int offsetMinutes) = Math.DivRem(offsetTotalMinutes, 60);
1759(int offsetHours, offsetMinutes) = Math.DivRem(offsetMinutes, 60);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int16.cs (7)
277public static (short Quotient, short Remainder) DivRem(short left, short right) => Math.DivRem(left, right);
608public static short Clamp(short value, short min, short max) => Math.Clamp(value, min, max);
620Math.ThrowNegateTwosCompOverflow();
627public static short Max(short x, short y) => Math.Max(x, y);
633public static short Min(short x, short y) => Math.Min(x, y);
639public static int Sign(short value) => Math.Sign(value);
655public static short Abs(short value) => Math.Abs(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int32.cs (8)
55public static long BigMul(int left, int right) => Math.BigMul(left, right);
292public static (int Quotient, int Remainder) DivRem(int left, int right) => Math.DivRem(left, right);
650public static int Clamp(int value, int min, int max) => Math.Clamp(value, min, max);
662Math.ThrowNegateTwosCompOverflow();
669public static int Max(int x, int y) => Math.Max(x, y);
675public static int Min(int x, int y) => Math.Min(x, y);
681public static int Sign(int value) => Math.Sign(value);
697public static int Abs(int value) => Math.Abs(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Int64.cs (8)
55public static Int128 BigMul(long left, long right) => Math.BigMul(left, right);
289public static (long Quotient, long Remainder) DivRem(long left, long right) => Math.DivRem(left, right);
647public static long Clamp(long value, long min, long max) => Math.Clamp(value, min, max);
659Math.ThrowNegateTwosCompOverflow();
666public static long Max(long x, long y) => Math.Max(x, y);
672public static long Min(long x, long y) => Math.Min(x, y);
678public static int Sign(long value) => Math.Sign(value);
694public static long Abs(long value) => Math.Abs(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (7)
322public static (nint Quotient, nint Remainder) DivRem(nint left, nint right) => Math.DivRem(left, right);
670public static nint Clamp(nint value, nint min, nint max) => Math.Clamp(value, min, max);
682Math.ThrowNegateTwosCompOverflow();
689public static nint Max(nint x, nint y) => Math.Max(x, y);
695public static nint Min(nint x, nint y) => Math.Min(x, y);
701public static int Sign(nint value) => Math.Sign(value);
717public static nint Abs(nint value) => Math.Abs(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.DecimalIeee754.cs (25)
363int positiveExponent = Math.Max(0, number.Scale);
364int integerDigitsPresent = Math.Min(positiveExponent, number.DigitsCount);
774int positiveExponent = (Math.Max(0, number.Scale));
775int integerDigitsPresent = Math.Min(positiveExponent, number.DigitsCount);
931int zeroExponent = Math.Min(a.UnbiasedExponent, b.UnbiasedExponent);
951int pad = Math.Min(nonZero.UnbiasedExponent - zeroExponent, TDecimal.Precision - nonZeroDigits);
976int effectiveDifference = Math.Min(exponentDifference, guard);
1341return DecimalIeee754FiniteNumberBinaryEncoding<TDecimal, TValue>(bothNegative, TValue.Zero, Math.Min(productExponent, addendExponent));
1350int pad = Math.Min(addendExponent - productExponent, TDecimal.Precision - addendDigits);
1354pad = Math.Min(pad, addendExponent - TDecimal.MinAdjustedExponent);
1366addendExponent = Math.Min(addendExponent, productExponent);
1373int maxMsd = Math.Max(productMsd, addendMsd);
1374int minLsd = Math.Min(productExponent, addendExponent);
1380int commonExponent = Math.Max(minLsd, maxMsd - retain + 1);
1667int resultExponent = Math.Min(a.UnbiasedExponent, b.UnbiasedExponent);
1699int step = Math.Min(chunk, gap);
1775int resultExponent = Math.Min(a.UnbiasedExponent, b.UnbiasedExponent);
1810int step = Math.Min(chunk, gap);
2023/// cases match <see cref="Math.ILogB(double)"/>, reporting <see cref="int.MinValue"/> for zero and
2078int zeroExponent = (int)Math.Clamp(exponent, TDecimal.MinAdjustedExponent, TDecimal.MaxAdjustedExponent);
2351int padding = Math.Min(TDecimal.Precision - TDecimal.CountDigits(significand), exponent - TDecimal.MinAdjustedExponent);
2513int chunk = Math.Min(power, highestTableExponent);
2537int step = Math.Min(dropCount, chunkPower);
2874int step = Math.Min(remaining, chunkPower);
3895return new decimal(0, 0, 0, decoded.Signed, (byte)Math.Clamp(-decoded.UnbiasedExponent, 0, 28));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.DecimalIeee754.DiyFp128.cs (10)
163ulong p2 = Math.BigMul(yHi, xLo, out _);
167ulong p1 = Math.BigMul(yLo, xHi, out _);
171p2 = Math.BigMul(yHi, xHi, out _);
193ulong tmp = Math.BigMul(yLo, xLo, out _);
209p2 = Math.BigMul(yHi, xLo, out _);
213p1 = Math.BigMul(yLo, xHi, out _);
217p2 = Math.BigMul(yHi, xHi, out _);
454ulong p11 = Math.BigMul(q1, b2, out _);
456ulong p00 = Math.BigMul(q1, b1, out _);
486q2 = Math.BigMul(bigR, n2, out _);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (33)
473for (int i = Math.Max(integerDigits, 0); i < digitCount; i++)
854int realDigits = Math.Min(precision, defaultHexDigits);
1026nMaxDigits = Math.Max(number.DigitsCount, TNumber.MaxRoundTripDigits);
1781(value, uint remainder) = Math.DivRem(value, 100);
1806int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((uint)(-value))) + sNegative.Length;
1824int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((uint)(-value))) + sNegative.Length;
1845int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((uint)value));
1861int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((uint)value));
1893int bufferLength = Math.Max(digits, 32 - (int)uint.LeadingZeroCount(value));
1909int bufferLength = Math.Max(digits, 32 - (int)uint.LeadingZeroCount(value));
1957(value, uint remainder) = Math.DivRem(value, 100);
2012int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value));
2041int bufferLength = Math.Max(digits, countedDigits);
2096int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((ulong)(-value))) + sNegative.Length;
2114int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((ulong)(-value))) + sNegative.Length;
2135int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((ulong)value));
2151int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((ulong)value));
2199int bufferLength = Math.Max(digits, 64 - (int)ulong.LeadingZeroCount(value));
2215int bufferLength = Math.Max(digits, 64 - (int)ulong.LeadingZeroCount(value));
2301(value, ulong remainder) = Math.DivRem(value, 100);
2337(value, ulong remainder) = Math.DivRem(value, 100);
2372(value, remainder) = Math.DivRem(value, 100);
2378(value, remainder) = Math.DivRem(value, 10);
2407int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value));
2434int bufferLength = Math.Max(digits, countedDigits);
2498int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(absValue)) + sNegative.Length;
2518int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(absValue)) + sNegative.Length;
2541int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits(uValue));
2559int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits(uValue));
2596int bufferLength = Math.Max(digits, 128 - (int)UInt128.LeadingZeroCount((UInt128)value));
2614int bufferLength = Math.Max(digits, 128 - (int)UInt128.LeadingZeroCount((UInt128)value));
2739int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value));
2749int bufferLength = Math.Max(digits, countedDigits);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\BigIntegerCalculator.Shared.cs (13)
105? Math.Min(GetLimbOffset(left), GetLimbOffset(right))
167int limbShift = Math.DivRem(exponent, BitsPerLimb, out int smallShift);
248(ulong q, ulong r) = Math.DivRem(lo, (ulong)divisor);
262(ulong q_hi, ulong r1) = Math.DivRem(((ulong)hi << 32) | lo_hi, divisor);
263(ulong q_lo, ulong r2) = Math.DivRem((r1 << 32) | lo_lo, divisor);
511if (Math.Max(leftOffset, rightOffset) >= 32)
543Debug.Assert(bits.Length == Math.Max(left.Length, right.Length) + 1);
559low.Slice(lowOffset, Math.Min(highOffset, low.Length) - lowOffset).CopyTo(bits[lowOffset..]);
570highOffset, Math.Max(lowOverlap.Length, highMagnitude.Length) + 1);
848uint convolutionLength = (uint)Math.Min(left.Length, repeatedLength);
955uint convolutionLength = (uint)Math.Min(left.Length, repeatedLength);
1139int limbShift = Math.DivRem(exponent, BitsPerLimb, out int smallShift);
1453quotient = (nuint)Math.BigMul((ulong)_magic, (ulong)value, out _);
src\runtime\src\libraries\System.Private.CoreLib\src\System\SByte.cs (7)
280public static (sbyte Quotient, sbyte Remainder) DivRem(sbyte left, sbyte right) => Math.DivRem(left, right);
587public static sbyte Clamp(sbyte value, sbyte min, sbyte max) => Math.Clamp(value, min, max);
599Math.ThrowNegateTwosCompOverflow();
606public static sbyte Max(sbyte x, sbyte y) => Math.Max(x, y);
612public static sbyte Min(sbyte x, sbyte y) => Math.Min(x, y);
618public static int Sign(sbyte value) => Math.Sign(value);
634public static sbyte Abs(sbyte value) => Math.Abs(value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (17)
137capacity = Math.Max(capacity, length);
161capacity = Math.Min(DefaultCapacity, maxCapacity);
209persistedCapacity = Math.Min(Math.Max(DefaultCapacity, persistedString.Length), persistedMaxCapacity);
457int capacityToPreserve = Math.Min(Capacity, Math.Max(Length * 6 / 5, m_ChunkChars.Length));
870int length = Math.Min(m_ChunkChars.Length - m_ChunkLength, count);
934chunkEndIndex = Math.Min(chunkEndIndex, chunk.m_ChunkLength);
2159ReadOnlySpan<char> remainingChunk = chunk.m_ChunkChars.AsSpan(indexInChunk, Math.Min(chunk.m_ChunkLength - indexInChunk, count));
2195Debug.Assert(oldValue.Length > Math.Min(count, chunk.m_ChunkLength - indexInChunk),
2281int curInChunk = Math.Max(startIndexInChunk, 0);
2282int endInChunk = Math.Min(chunk.m_ChunkLength, endIndexInChunk);
2560int lengthToCopy = Math.Min(lengthInChunk, count);
2646int newBlockLength = Math.Max(minBlockCharCount, Math.Min(Length, MaxChunkSize));
2754StringBuilder newChunk = new StringBuilder(Math.Max(count, DefaultCapacity), chunk.m_MaxCapacity, chunk.m_ChunkPrevious);
2758int copyCount1 = Math.Min(count, indexInChunk);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.Blocking.cs (14)
15return Math.Min(_separated.counts.NumThreadsGoal, TargetThreadsGoalForBlockingAdjustment);
28: (short)Math.Min((ushort)(_minThreads + _numBlockedThreads), (ushort)_maxThreads);
146short toSubtract = Math.Min((short)(numThreadsGoal - targetThreadsGoal), _numThreadsAddedDueToBlocking);
157(short)Math.Min((ushort)(_minThreads + BlockingConfig.ThreadsToAddWithoutDelay), (ushort)_maxThreads);
164Math.Max(configuredMaxThreadsWithoutDelay, Math.Min(counts.NumExistingThreads, _maxThreads));
165short targetThreadsGoalWithoutDelay = Math.Min(targetThreadsGoal, maxThreadsGoalWithoutDelay);
221newNumThreadsGoal = (short)Math.Min(newNumThreadsGoal, achievableNumThreadsGoal);
250return Math.Min((uint)delayStepCount * BlockingConfig.DelayStepMs, BlockingConfig.MaxDelayMs);
328blocking_threadsPerDelayStep_procCountFactor = Math.Max(1, blocking_threadsPerDelayStep_procCountFactor);
338MaxDelayMs = Math.Max(1, Math.Min(MaxDelayMs, GateThread.GateActivitiesPeriodMs));
339DelayStepMs = Math.Max(1, Math.Min(DelayStepMs, MaxDelayMs));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.HillClimbing.cs (21)
200int sampleCount = ((int)Math.Min(_totalSamples - 1, _samplesToMeasure)) / _wavePeriod * _wavePeriod;
235throughputErrorEstimate = Math.Max(throughputErrorEstimate, (GetWaveComponent(_samples, sampleCount, adjacentPeriod2) / averageThroughput).Abs());
271double noiseForConfidence = Math.Max(_averageThroughputNoise, throughputErrorEstimate);
288double move = Math.Min(1.0, Math.Max(-1.0, ratio.Real));
293move *= Math.Min(1.0, Math.Max(0.0, confidence));
301move = Math.Pow(Math.Abs(move), _gainExponent) * (move >= 0.0 ? 1 : -1) * gain;
302move = Math.Min(move, _maxChangePerSample);
321newThreadWaveMagnitude = Math.Min(newThreadWaveMagnitude, _maxThreadWaveMagnitude);
322newThreadWaveMagnitude = Math.Max(newThreadWaveMagnitude, 1);
332_currentControlSetting = Math.Min(maxThreads - newThreadWaveMagnitude, _currentControlSetting);
333_currentControlSetting = Math.Max(minThreads, _currentControlSetting);
343newThreadCount = Math.Min(maxThreads, newThreadCount);
344newThreadCount = Math.Max(minThreads, newThreadCount);
380newSampleInterval = (int)(0.5 + _currentSampleMs * (1.0 + 9.0 * Math.Min(-ratio.Real, 1.0)));
419entry.lastHistoryCount = (int)(Math.Min(_totalSamples, _samplesToMeasure) / _wavePeriod) * _wavePeriod;
453double w = 2 * Math.PI / period;
454double cos = Math.Cos(w);
463return new Complex(q1 - q2 * cos, q2 * Math.Sin(w)) / numSamples;
src\runtime\src\libraries\System.Private.CoreLib\src\System\TimeSpan.cs (22)
294Int128 totalMicroseconds = Math.BigMul(days, MicrosecondsPerDay)
295+ Math.BigMul(hours, MicrosecondsPerHour)
296+ Math.BigMul(minutes, MicrosecondsPerMinute)
297+ Math.BigMul(seconds, MicrosecondsPerSecond)
298+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond)
473Int128 totalMicroseconds = Math.BigMul(days, MicrosecondsPerDay)
474+ Math.BigMul(hours, MicrosecondsPerHour)
475+ Math.BigMul(minutes, MicrosecondsPerMinute)
476+ Math.BigMul(seconds, MicrosecondsPerSecond)
477+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond)
509Int128 totalMicroseconds = Math.BigMul(hours, MicrosecondsPerHour)
510+ Math.BigMul(minutes, MicrosecondsPerMinute)
511+ Math.BigMul(seconds, MicrosecondsPerSecond)
512+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond)
543Int128 totalMicroseconds = Math.BigMul(minutes, MicrosecondsPerMinute)
544+ Math.BigMul(seconds, MicrosecondsPerSecond)
545+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond)
575Int128 totalMicroseconds = Math.BigMul(seconds, MicrosecondsPerSecond)
576+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond)
606Int128 totalMicroseconds = Math.BigMul(milliseconds, MicrosecondsPerMillisecond)
917double ticks = Math.Round(timeSpan.Ticks * factor);
932double ticks = Math.Round(timeSpan.Ticks / divisor);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt128.cs (11)
838ulong chkHi = Math.BigMul(divHi, q, out ulong chkHiLo);
839ulong chkLoHi = Math.BigMul(divLo, q, out ulong chkLo);
888(highRes, leftUpper) = Math.DivRem(left._upper, divisor);
943Debug.Assert(Math.BigMul(quo, divisor) + rem == (new UInt128(hi, lo)));
979ulong chkHiUL = Math.BigMul(divisor, q, out ulong chkLo);
1379ulong upper = Math.BigMul(left._lower, right._lower, out ulong lower);
1416UInt128 mull = Math.BigMul(al, bl);
1417UInt128 t = Math.BigMul(ah, bl) + mull._upper;
1418UInt128 tl = Math.BigMul(al, bh) + t._lower;
1421return Math.BigMul(ah, bh) + t._upper + tl._upper;
1433Math.ThrowMinMaxException(min, max);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt16.cs (4)
271public static (ushort Quotient, ushort Remainder) DivRem(ushort left, ushort right) => Math.DivRem(left, right);
526public static ushort Clamp(ushort value, ushort min, ushort max) => Math.Clamp(value, min, max);
532public static ushort Max(ushort x, ushort y) => Math.Max(x, y);
538public static ushort Min(ushort x, ushort y) => Math.Min(x, y);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt32.cs (5)
52public static ulong BigMul(uint left, uint right) => Math.BigMul(left, right);
287public static (uint Quotient, uint Remainder) DivRem(uint left, uint right) => Math.DivRem(left, right);
591public static uint Clamp(uint value, uint min, uint max) => Math.Clamp(value, min, max);
597public static uint Max(uint x, uint y) => Math.Max(x, y);
603public static uint Min(uint x, uint y) => Math.Min(x, y);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UInt64.cs (5)
52public static UInt128 BigMul(ulong left, ulong right) => Math.BigMul(left, right);
286public static (ulong Quotient, ulong Remainder) DivRem(ulong left, ulong right) => Math.DivRem(left, right);
598public static ulong Clamp(ulong value, ulong min, ulong max) => Math.Clamp(value, min, max);
604public static ulong Max(ulong x, ulong y) => Math.Max(x, y);
610public static ulong Min(ulong x, ulong y) => Math.Min(x, y);
src\runtime\src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (4)
318public static (nuint Quotient, nuint Remainder) DivRem(nuint left, nuint right) => Math.DivRem(left, right);
597public static nuint Clamp(nuint value, nuint min, nuint max) => Math.Clamp(value, min, max);
603public static nuint Max(nuint x, nuint y) => Math.Max(x, y);
609public static nuint Min(nuint x, nuint y) => Math.Min(x, y);
System.Private.CoreLib.Generators (3)
System.Private.DataContractSerialization (52)
System\Xml\XmlBaseReader.cs (6)
1148actual = Math.Min(count, value.Length);
1178return ReadBytes(DataContractSerializer.Base64Encoding, 3, 4, buffer, offset, Math.Min(count, 512), false);
1370return ReadBytes(DataContractSerializer.Base64Encoding, 3, 4, buffer, offset, Math.Min(count, 512), true);
1390return ReadBytes(DataContractSerializer.BinHexEncoding, 1, 2, buffer, offset, Math.Min(count, 512), true);
1425int actual = Math.Min(_trailByteCount, byteCount);
1493int actual = Math.Min(_trailByteCount, byteCount);
System\Xml\XmlBinaryReader.cs (15)
882int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0);
894int actual = Math.Max(maxLength - maxTextNodeLength, 0);
952int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0);
964int actual = Math.Max(maxLength - maxTextNodeLength, 0);
994int maxBytesPerRead = Math.Max(_maxBytesPerRead - nodeLength, 0);
1232int actual = Math.Min(count, _arrayCount);
1255int actual = Math.Min(count, _arrayCount);
1278int actual = Math.Min(count, _arrayCount);
1301int actual = Math.Min(count, _arrayCount);
1324int actual = Math.Min(count, _arrayCount);
1347int actual = Math.Min(count, _arrayCount);
1370int actual = Math.Min(count, _arrayCount);
1394int actual = Math.Min(count, _arrayCount);
1423int actual = Math.Min(count, _arrayCount);
1459int actual = Math.Min(count, _arrayCount);
System.Private.Reflection.Execution (1)
System.Private.TypeLoader (3)
System.Private.Uri (5)
System.Private.Windows.Core (7)
System.Private.Xml (32)
System.Reflection.Emit (3)
System.Reflection.Metadata (19)
System.Reflection.MetadataLoadContext (2)
System.Runtime (1)
System.Runtime.Caching (17)
System.Runtime.Extensions (1)
System.Runtime.Numerics (85)
src\runtime\src\libraries\Common\src\System\Number.Formatting.Common.cs (16)
284(value, uint remainder) = Math.DivRem(value, 100);
312(value, remainder) = Math.DivRem(value, 100);
318(value, remainder) = Math.DivRem(value, 10);
718digits = digits.Slice(0, Math.Min(number.DigitsCount, digits.Length));
735ReadOnlySpan<byte> adjustDigits = digits.Slice(0, Math.Min(adjust, digits.Length));
994dig = dig.Slice(0, Math.Min(number.DigitsCount, dig.Length));
1032ReadOnlySpan<byte> intDigits = dig.Slice(0, Math.Min(digPos, dig.Length));
1039int digitsInGroup = (groupSize > 0) ? Math.Min(groupSize, remainingDigits) : remainingDigits;
1082int actualDigits = Math.Min(digPos, dig.Length);
1106int zeroes = Math.Min(-digPos, nMaxDigits);
1115int decActual = Math.Min(nMaxDigits, remainingDig);
1201dig = dig.Slice(0, Math.Min(number.DigitsCount, dig.Length));
1215foreach (byte b in dig.Slice(1, Math.Min(nMaxDigits - 1, dig.Length - 1)))
1249int digitCount = Math.Max(minDigits, FormattingHelpers.CountDigits((uint)value));
1273dig = dig.Slice(0, Math.Min(number.DigitsCount, dig.Length));
1278int intCount = Math.Min(digPos, dig.Length);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Numerics\BigIntegerCalculator.Shared.cs (13)
105? Math.Min(GetLimbOffset(left), GetLimbOffset(right))
167int limbShift = Math.DivRem(exponent, BitsPerLimb, out int smallShift);
248(ulong q, ulong r) = Math.DivRem(lo, (ulong)divisor);
262(ulong q_hi, ulong r1) = Math.DivRem(((ulong)hi << 32) | lo_hi, divisor);
263(ulong q_lo, ulong r2) = Math.DivRem((r1 << 32) | lo_lo, divisor);
511if (Math.Max(leftOffset, rightOffset) >= 32)
543Debug.Assert(bits.Length == Math.Max(left.Length, right.Length) + 1);
559low.Slice(lowOffset, Math.Min(highOffset, low.Length) - lowOffset).CopyTo(bits[lowOffset..]);
570highOffset, Math.Max(lowOverlap.Length, highMagnitude.Length) + 1);
848uint convolutionLength = (uint)Math.Min(left.Length, repeatedLength);
955uint convolutionLength = (uint)Math.Min(left.Length, repeatedLength);
1139int limbShift = Math.DivRem(exponent, BitsPerLimb, out int smallShift);
1453quotient = (nuint)Math.BigMul((ulong)_magic, (ulong)value, out _);
System\Number.BigInteger.cs (7)
394ReadOnlySpan<byte> intDigits= number.Digits.Slice(0, Math.Min(number.Scale, number.DigitsCount));
447int totalDigitCount = Math.Min(number.DigitsCount, number.Scale);
470int powersOf1e9BufferLength = PowersOf1e9.GetBufferSize(Math.Max(valueDigits, trailingZeroCount + 1), out int maxIndex);
544int trailingPartialCount = Math.DivRem(trailingZeroCount, PowersOf1e9.MaxPartialDigits, out int remainingTrailingZeroCount);
735int charsIncludeDigits = Math.Max(digits, charsForBits);
884int strDigits = Math.Max(digits, valueDigits);
1487int trailingPartialCount = Math.DivRem(trailingZeroCount, MaxPartialDigits, out int remainingTrailingZeroCount);
System\Numerics\BigInteger.cs (30)
410int wholeLimbCount = Math.DivRem(byteCount, nint.Size, out int unalignedBytes);
924(int q, int r) = Math.DivRem(dividend._sign, divisor._sign);
1007return Log(value, Math.E);
1029return Math.Log(value._sign, baseValue);
1064return Math.Log(x, baseValue) + (b - 64) / Math.Log(baseValue, 2);
1086return CreatePowerOfTwo(Math.Min(powerOfTwoExponent, GetTrailingZeroCount(right)), negative: false);
1091return CreatePowerOfTwo(Math.Min(powerOfTwoExponent, GetTrailingZeroCount(left)), negative: false);
1269int limbCount = Math.DivRem(exponent, bitsPerLimb, out int partialBits);
1286int digitShift = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb, out int smallShift);
2059msbIndex = Math.Max(0, bytesPerLimb - 1 - (lzc / 8));
2065msbIndex = Math.Max(0, bytesPerLimb - 1 - (lzc / 8));
2214int msb = Math.Max(0, buffer[..^1].LastIndexOfAnyExcept(highLimb));
2294double significand = highBits * Math.Pow(10, exponentLow - exponent);
2297double log10 = Math.Log10(significand);
2301significand /= Math.Pow(10, Math.Floor(log10));
2306significand = Math.Round(significand, 8);
2489int size = Math.Max(leftBits.Length, rightBits.Length) + 1;
2525int size = Math.Max(leftBits.Length, rightBits.Length);
3237? Math.Max(xLen, yLen) + 1
3238: Math.Min(xLen, yLen) + 1;
3250return BitwiseOp<BigIntegerCalculator.BitwiseOrOp>(in left, in right, Math.Max(xLen, yLen) + 1);
3260return BitwiseOp<BigIntegerCalculator.BitwiseXorOp>(in left, in right, Math.Max(xLen, yLen) + 1);
3297(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb);
3411(int digitShift, int smallShift) = Math.DivRem(shift, BigIntegerCalculator.BitsPerLimb);
4093Debug.Assert(Math.Abs(rotateLeftAmount) <= 0x80000000);
4164(digitShift32, smallShift32) = Math.DivRem(-(int)rotateLeftAmount, BitsPerUInt32);
4170(digitShift32, smallShift32) = Math.DivRem((int)rotateLeftAmount, BitsPerUInt32);
6019(int digitShift, int smallShift) = Math.DivRem(shiftAmount, BigIntegerCalculator.BitsPerLimb);
System.Runtime.Serialization.Formatters (3)
System.Runtime.Serialization.Schema (1)
System.Security.Cryptography (22)
System.Security.Cryptography.Cose (2)
System.Security.Cryptography.Pkcs (5)
System.ServiceModel.Federation (1)
System.ServiceModel.Http (3)
System.ServiceModel.NetFramingBase (11)
System\ServiceModel\Channels\SingletonConnectionReader.cs (8)
351int bytesToCopy = Math.Min(_chunkBytesRemaining,
352Math.Min(_chunkBufferSize, count));
377bytesToRead = Math.Min(count, _chunkBytesRemaining + IntEncoder.MaxEncodedSize);
383DecodeData(buffer, offset, Math.Min(bytesRead, _chunkBytesRemaining));
455int bytesToCopy = Math.Min(_chunkBytesRemaining,
456Math.Min(_chunkBufferSize, count));
481bytesToRead = Math.Min(count, _chunkBytesRemaining + IntEncoder.MaxEncodedSize);
487DecodeData(buffer, offset, Math.Min(bytesRead, _chunkBytesRemaining));
System.ServiceModel.NetNamedPipe (1)
System.ServiceModel.Primitives (38)
System\ServiceModel\Channels\TransmissionStrategy.cs (20)
89_meanRtt = Math.Min((long)initRtt.TotalMilliseconds, Constants.MaxMeanRtt >> Constants.TimeMultiplier) << Constants.TimeMultiplier;
93_timeout = Math.Max(((200 << Constants.TimeMultiplier) * 2) + _meanRtt, _meanRtt + (_serrRtt << Constants.ChebychevFactor));
259int count = Math.Min(_windowSize, QuotaRemaining) - _window.Count;
263count = Math.Min(count, _waitQueue.Count);
299_slowStartThreshold = Math.Max(1, _windowSize >> 1);
592QuotaRemaining = quotaRemaining - Math.Min(_windowSize, _window.Count);
631int inFlightAfterAck = Math.Min(_windowSize, _window.Count) - (int)slide;
632QuotaRemaining = quotaRemaining - Math.Max(0, inFlightAfterAck);
643_windowSize = Math.Min(_maxWindowSize, Math.Min(_slowStartThreshold + 1, _windowSize + (int)slide));
648sendBeginIndex = Math.Max(0, (int)oldWindowEnd - (int)_windowStart);
655int segmentSize = Math.Max(1, (_lossWindowSize - _slowStartThreshold) / 8);
661_windowSize = Math.Min(_maxWindowSize, _windowSize + 1);
664sendBeginIndex = Math.Max(0, (int)oldWindowEnd - (int)_windowStart);
667int sendEndIndex = Math.Min(_windowSize, _window.Count);
732now = Math.Max(now, lastAttemptTime);
735_serrRtt = Math.Min(_serrRtt + ((Math.Abs(error) - _serrRtt) >> Constants.Gain), Constants.MaxSerrRtt);
736_meanRtt = Math.Min(_meanRtt + (error >> Constants.Gain), Constants.MaxMeanRtt);
737_timeout = Math.Max(((200 << Constants.TimeMultiplier) * 2) + _meanRtt, _meanRtt + (_serrRtt << Constants.ChebychevFactor));
System.ServiceModel.Syndication (1)
System.ServiceProcess.ServiceController (2)
System.Speech (9)
System.Text.Encodings.Web (6)
System.Text.Json (22)
System.Text.Json.SourceGeneration (4)
System.Text.RegularExpressions (42)
System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (9)
114int reps = node.Kind is RegexNodeKind.One ? 1 : Math.Min(node.M, MaxPrefixLength);
164int reps = node.Kind is RegexNodeKind.Set ? 1 : Math.Min(node.M, MaxPrefixLength);
228int limit = Math.Min(node.M, MaxPrefixLength); // MaxPrefixLength here is somewhat arbitrary, as a single loop iteration could yield multiple chars
434int count = Math.Min(node.M, SingleCharIterationLimit);
442int limit = Math.Min(node.M, NodeIterationLimit);
612int minIterations = Math.Min(node.M, MaxLoopExpansion);
643int minIterations = Math.Min(node.M, MaxLoopExpansion);
856int c = Math.Max(s1CharsLength, s1RangeLength).CompareTo(Math.Max(s2CharsLength, s2RangeLength));
System.Text.RegularExpressions.Generator (28)
parent\src\System\Text\RegularExpressions\RegexPrefixAnalyzer.cs (9)
114int reps = node.Kind is RegexNodeKind.One ? 1 : Math.Min(node.M, MaxPrefixLength);
164int reps = node.Kind is RegexNodeKind.Set ? 1 : Math.Min(node.M, MaxPrefixLength);
228int limit = Math.Min(node.M, MaxPrefixLength); // MaxPrefixLength here is somewhat arbitrary, as a single loop iteration could yield multiple chars
434int count = Math.Min(node.M, SingleCharIterationLimit);
442int limit = Math.Min(node.M, NodeIterationLimit);
612int minIterations = Math.Min(node.M, MaxLoopExpansion);
643int minIterations = Math.Min(node.M, MaxLoopExpansion);
856int c = Math.Max(s1CharsLength, s1RangeLength).CompareTo(Math.Max(s2CharsLength, s2RangeLength));
System.Threading (2)
System.Threading.Channels (1)
System.Threading.RateLimiting (3)
System.Threading.Tasks.Dataflow (1)
System.Threading.Tasks.Parallel (1)
System.Web.HttpUtility (2)
System.Windows.Controls.Ribbon (105)
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGalleryCategoriesPanel.cs (10)
383maxChildWidth = Math.Max(maxChildWidth, childSize.Width);
384maxChildHeight = Math.Max(maxChildHeight, childSize.Height);
458stackDesiredSize.Width = Math.Max(stackDesiredSize.Width, childDesiredSize.Width);
468stackDesiredSize.Width = Math.Min(stackDesiredSize.Width, constraint.Width);
469stackDesiredSize.Height = Math.Min(stackDesiredSize.Height, constraint.Height);
488logicalVisibleSpace = DoubleUtil.LessThanOrClose((viewportOffsetY + logicalVisibleSpace) - stackDesiredSize.Height, 0.0) ? 0.0 : Math.Min((viewportOffsetY + logicalVisibleSpace) - stackDesiredSize.Height, constraint.Height);
489viewportOffsetY = Math.Max(viewportOffsetY - logicalVisibleSpace, 0.0);
492offset.X = Math.Max(0, Math.Min(offset.X, extent.Width - viewport.Width));
598rcChild.Width = Math.Max(finalSize.Width, child.DesiredSize.Width);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGalleryItemsPanel.cs (25)
340maxColumnWidth = Math.Max(maxColumnWidth, childSize.Width);
341maxItemHeight = Math.Max(maxItemHeight, childSize.Height);
362columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / maxColumnWidth), childrenCount)), maxColumnCount);
374columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / maxColumnWidth), childrenCount)), maxColumnCount);
375arrangeWidth = Math.Max(availableSize.Width / columnCount, maxColumnWidth);
381columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / arrangeWidth), childrenCount)), maxColumnCount);
390columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / maxColumnWidth), childrenCount)), maxColumnCount);
391_arrangeWidth = Math.Max(availableSize.Width / columnCount, maxColumnWidth);
397columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / _arrangeWidth), childrenCount)), maxColumnCount);
404columnCount = Math.Max(minColumnCount, Math.Min(childrenCount, maxColumnCount));
413maxRowHeight = Math.Max(maxRowHeight, childSize.Height);
566finalColumnCount = Math.Max(minColumnCount, Math.Min((int)(finalSize.Width / arrangeWidth), maxColumnCount));
575maxRowHeight = Math.Max(maxRowHeight, children[i].DesiredSize.Height);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGroupItemsPanel.cs (14)
82remainingHeightInColumn = Math.Max(0, finalSize.Height - childDesiredSize.Height);
104columnWidth = Math.Max(columnWidth, arrangeWidth);
132maxStarColumnWidth = Math.Max(maxStarColumnWidth, child.MaxWidth);
137maxStarColumnWidth = Math.Max(maxStarColumnWidth, Math.Min(child.MaxWidth, child.DesiredSize.Width));
219desiredHeight = Math.Min(Math.Max(desiredHeight, columnHeight), availableSize.Height);
244columnWidth = Math.Max(columnWidth, GetStarChildMinWidth(child as FrameworkElement, ref maxStarColumnWidth));
248columnWidth = Math.Max(columnWidth, childDesiredSize.Width);
249maxStarColumnWidth = Math.Max(maxStarColumnWidth, columnWidth);
254desiredHeight = Math.Min(Math.Max(desiredHeight, columnHeight), availableSize.Height);
354columnDesiredWidth = Math.Max(columnDesiredWidth, child.DesiredSize.Width);
371desiredWidth += Math.Max((columnDesiredWidth - starLayoutInfo.RequestedStarMinWidth), 0);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonTabHeadersPanel.cs (11)
89_separatorOpacity = Math.Max(0.0, reducePaddingRegularTabHeader * 0.2);
122double availableExtraWidth = Math.Min(desiredExtraPaddingPerTab, availableExtraWidthPerTab);
142if (Math.Abs(desiredSize.Width - availableSize.Width) < _desiredWidthEpsilon)
395desiredSize.Height = Math.Max(desiredSize.Height, ribbonTabHeader.DesiredSize.Height);
412desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height);
443double leftPadding = Math.Max(0, ribbonTabHeader.DefaultPadding.Left - (isContextualTab ? reducePaddingContextualTabHeader : reducePaddingRegularTabHeader));
444double rightPadding = Math.Max(0, ribbonTabHeader.DefaultPadding.Right - (isContextualTab ? reducePaddingContextualTabHeader : reducePaddingRegularTabHeader));
450desiredSize.Height = Math.Max(desiredSize.Height, ribbonTabHeader.DesiredSize.Height);
461desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height);
526return Math.Max(_tabHeaderMinWidth, maxTabHeaderWidth);
1048return Math.Max(0.0, offset);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonTitlePanel.cs (14)
76startContextualTabX = Math.Min(CalculateContextualTabGroupStartX(firstContextualTab), availableSize.Width);
82endContextualTabX = Math.Min(CalculateContextualTabGroupEndX(lastContextualTab), availableSize.Width);
85groupHeaderItemsControl.Measure(new Size(Math.Max(endContextualTabX - startContextualTabX, 0), availableSize.Height));
87desiredSize.Height = Math.Max(desiredSize.Height, groupHeaderItemsControl.DesiredSize.Height);
122availableToQat = Math.Max(availableToQat, 0);
129desiredSize.Height = Math.Max(desiredSize.Height, qat.DesiredSize.Height);
134endContextualTabX = Math.Max(endContextualTabX, availableToQat);
147availableToTitle = Math.Max(leftSpace, rightSpace);
153availableToTitle = Math.Max(availableToTitle, 0);
157desiredSize.Height = Math.Max(desiredSize.Height, titleHost.DesiredSize.Height);
160desiredSize.Width = Math.Min(desiredSize.Width, availableSize.Width); // Prevent clipping
185startContextualTabX = Math.Min(CalculateContextualTabGroupStartX(firstContextualTab), finalSize.Width);
188endContextualTabX = Math.Min(startContextualTabX + tabGroups.DesiredSize.Width, finalSize.Width);
201endContextualTabX = Math.Max(endContextualTabX, qatDesiredWidth);
System.Windows.Forms (858)
System.Windows.Forms.Design (181)
System.Windows.Forms.Primitives (27)
System.Windows.Input.Manipulations (34)
System.Xaml (1)
Terminals.AppHost (1)
UIAutomationClientSideProviders (27)
MS\Internal\AutomationProxies\WindowsEditBoxRange.cs (13)
127End = Math.Min(Math.Max(End, Start + 1), text.Length);
161End = Math.Min(Math.Max(End, Start + 1), text.Length);
295return text.Substring(Start, maxLength >= 0 ? Math.Min(Length, maxLength) : Length);
469Math.Max(0, _provider.LineFromChar(End) - _provider.LinesPerPage() + 1);
654int height = Math.Abs(_provider.GetLogfont().lfHeight);;
681ArrayList rects = new ArrayList(Math.Max(endLine - startLine + 1, 0));
776return Math.Round((double)(-logfont.lfHeight) * 72 / lpy);
823moved = Math.Min(count, limit - index);
868moved = Math.Min(count, lineMax - line - 1);
936moved = Math.Max(count, -oneBasedIndex);
981int actualCount = Math.Max(count, -line);
UIAutomationTypes (3)
VBCSCompiler (1)
vstest.console (1)
vstest.console.arm64 (1)
WindowsFormsIntegration (13)