7173 references to Math
AnalyzerRunner (1)
DiagnosticAnalyzerRunner.cs (1)
197return new DocumentAnalyzerPerformance(analyzerOptionsInternal.TestDocumentIterations / stopwatch.Elapsed.TotalSeconds, stopwatch.AllocatedBytes / Math.Max(1, analyzerOptionsInternal.TestDocumentIterations));
Aspire.Dashboard (17)
Components\Controls\Chart\ChartBase.cs (1)
456dimensionValue = Math.Max(value, dimensionValue);
Components\Controls\Chart\MetricTable.razor.cs (1)
222return Math.Abs(a.Value - b.Value) < 0.00002; // arbitrarily small number
Components\Controls\Chart\PlotlyChart.razor.cs (1)
135var index = (int)Math.Floor(j * step);
Components\Controls\SummaryDetailsView.razor.cs (3)
120var fraction = Math.Clamp(panel1FractionResult.Value, 0, 1); 166var fraction = Math.Clamp(panel1FractionResult.Value, 0, 1); 204await LocalStore.SetUnprotectedAsync(GetSizeStorageKey(), Math.Round(panel1Fraction, 3));
Components\Pages\Resources.razor.cs (2)
279maxHighlightedCount = Math.Max(maxHighlightedCount, resourceHighlightedCount); 284_maxHighlightedCount = Math.Min(maxHighlightedCount, DashboardUIHelpers.MaxHighlightedCommands);
Otlp\Model\DurationFormatter.cs (2)
40var primaryValue = Math.Floor(ticks / primaryUnit.Ticks); 42var secondaryValue = Math.Round((ticks / secondaryUnit.Ticks) % ofPrevious, MidpointRounding.AwayFromZero);
Otlp\Model\OtlpHelpers.cs (4)
178var values = new KeyValuePair<string, string>[Math.Min(attributes.Count, context.Options.MaxAttributeCount)]; 198var readLimit = Math.Min(attributes.Count, context.Options.MaxAttributeCount); 250copyCount = Math.Min(parentAttributes.Length + attributes.Count, context.Options.MaxAttributeCount); 278var desiredCopyCount = Math.Min(attributes.Count + index, context.Options.MaxAttributeCount);
ResourceService\DashboardClient.cs (2)
318return TimeSpan.FromSeconds(Math.Min(Math.Pow(2, errorCount - 1), maxSeconds));
Utils\ValueExtensions.cs (1)
23i = (int)Math.Round(value.NumberValue);
Aspire.Hosting (1)
Utils\PasswordGenerator.cs (1)
43var length = Math.Max(minLength, requiredMinLength);
Aspire.Playground.Tests (1)
src\Aspire.Hosting\Utils\PasswordGenerator.cs (1)
43var length = Math.Max(minLength, requiredMinLength);
BuildActionTelemetryTable (2)
Program.cs (1)
600var startIndex = Math.Max(0, descriptionParts.Length - 2);
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
CodeGenerator (8)
HttpUtilities\HttpUtilities.cs (4)
34var maskLength = (byte)Math.Ceiling(Math.Log(httpMethods.Length, 2)); 58int knownMethodsArrayLength = (int)(Math.Pow(2, maskLength) + 1); 218var mask2 = (ulong)(Math.Pow(2, bitsCount) - 1);
HttpUtilities\HttpUtilitiesGeneratorHelpers.cs (4)
191var maskSizeInBIts = Math.Log(mask, 2); 192var hexMaskSize = Math.Ceiling(maskSizeInBIts / 4.0); 210var maskSizeInBIts = Math.Log(mask, 2); 211var hexMaskSize = (byte)Math.Ceiling(maskSizeInBIts / 4);
dotnet-svcutil-lib (84)
FrameworkFork\Microsoft.Xml\Xml\BinaryXml\SqlUtils.cs (2)
223bNewPrec = (byte)(Math.Min(s_NUMERIC_MAX_PRECISION, Math.Max(1, lAdjust + m_bPrec)));
FrameworkFork\Microsoft.Xml\Xml\Dom\XmlCharacterData.cs (2)
143count = Math.Max(len - offset, 0); 171count = Math.Max(len - offset, 0);
FrameworkFork\Microsoft.Xml\Xml\schema\BitSet.cs (1)
231int i = Math.Min(_bits.Length, other._bits.Length);
FrameworkFork\Microsoft.Xml\Xml\Serialization\XmlSerializationReader.cs (2)
506currentSize = Math.Min(currentSize * 2, MAX_ALLOC_SIZE); 527currentSize = Math.Min(block.Length, total);
FrameworkFork\Microsoft.Xml\Xml\XmlConvert.cs (1)
1271double temp = Math.Round(value);
FrameworkFork\Microsoft.Xml\Xml\XPath\Internal\NumberFunctions.cs (2)
104return Math.Floor((double)_arg.Evaluate(nodeIterator)); 109return Math.Ceiling((double)_arg.Evaluate(nodeIterator));
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\CodeExporter.cs (1)
1453length = Math.Min(MaxIdentifierLength, length);
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\SchemaExporter.cs (1)
29return isFlags ? (long)Math.Pow(2, index) : index;
FrameworkFork\System.Runtime.Serialization\System\Runtime\Serialization\XmlReaderDelegator.cs (1)
626return Math.Min(context.RemainingItemCount, int.MaxValue);
FrameworkFork\System.Runtime.Serialization\System\Xml\ArrayHelper.cs (1)
66count = Math.Min(count, 256);
FrameworkFork\System.Runtime.Serialization\System\Xml\EncodingStreamWrapper.cs (2)
340int max = offset + Math.Min(count, BufferLength); 508int inputCount = Math.Min(count, BufferLength * 2);
FrameworkFork\System.Runtime.Serialization\System\Xml\ValueHandle.cs (4)
627actual = Math.Min(_length, count); 637int charCount = Math.Min(count / 3 * 4, _length); 707actualByteCount = Math.Min(charCount, byteCount); 772int charCount = Math.Min(count, _length / sizeof(char));
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);
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlBinaryReaderSession.cs (3)
47_strings = new XmlDictionaryString[Math.Max(id + 1, 16)]; 51XmlDictionaryString[] newStrings = new XmlDictionaryString[Math.Min(Math.Max(id + 1, _strings.Length * 2), MaxArrayEntries)];
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlBinaryWriterSession.cs (2)
65IntArray keys = new IntArray(Math.Max(minCount, 16)); 252int[] newArray = new int[Math.Max(index + 1, _array.Length * 2)];
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlBufferReader.cs (6)
168TryEnsureBytes(Math.Min(count, _windowOffsetMax - offset)); 225byte[] newBuffer = new byte[Math.Max(newOffsetMax, _buffer.Length * 2)]; 280_windowOffsetMax = Math.Max(windowOffset + windowLength, _offsetMax); 970int length = Math.Min(byteLength, charLength); 984int length = Math.Min(byteLength, charLength); 1016int length = Math.Min(length1, length2);
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlConverter.cs (2)
1113offset += ToCharsD2(Math.Abs(ts.Hours), chars, offset); 1115offset += ToCharsD2(Math.Abs(ts.Minutes), chars, offset);
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlStreamNodeWriter.cs (1)
471int toCopy = Math.Min(newBytes.Length, (int)(bytesMax - bytes));
FrameworkFork\System.Runtime.Serialization\System\Xml\XmlUTF8TextWriter.cs (2)
759int byteCount = Math.Min(bufferLength / 4 * 3, count - count % 3); 780int byteCount = Math.Min(bufferLength / 4 * 3, count - count % 3);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\BufferedWriteStream.cs (2)
85byte[] shadowBuffer = new byte[Math.Min(_bufferSize + _bufferSize, MaxShadowBufferSize)]; 237int bytesToWrite = Math.Min(_bufferSize - _writePos, count);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\Connection.cs (3)
160int bytesToCopy = Math.Min(size, _preReadCount); 176int bytesToCopy = Math.Min(size, _preReadCount); 381AsyncCompletionResult asyncCompletionResult = _connection.BeginRead(0, Math.Min(count, _connection.AsyncReadBufferSize),
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\CoreClrSocketConnection.cs (3)
536size = Math.Min(bytesToWrite, maxSocketWrite); 878long delta = Math.Max(oldTimeout.Ticks, newTimeout.Ticks) - Math.Min(oldTimeout.Ticks, newTimeout.Ticks);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\FramingChannels.cs (2)
453Math.Min(FaultStringDecoder.FaultSizeQuota, connection.AsyncReadBufferSize), 479Math.Min(FaultStringDecoder.FaultSizeQuota, connection.AsyncReadBufferSize),
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\MaxMessageSizeStream.cs (1)
105return Math.Min(bytesToRead, (int)(_maxMessageSize - _totalBytesRead));
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\MessageEncoder.cs (2)
62int currentBufferSize = Math.Min(buffer.Length, maxBufferSize); 81currentBufferSize = Math.Min(currentBufferSize * 2, maxBufferSize);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\MessageEncoderCompressionHandler.cs (1)
20int maxDecompressedSize = (int)Math.Min(maxReceivedMessageSize, int.MaxValue);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\ProducerConsumerStream.cs (1)
273int bytesToCopy = Math.Min(_count, srcCount);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\UdpRetransmissionSettings.cs (4)
267long diff = Math.Abs(ts1.Ticks - ts2.Ticks); 268long max = Math.Max(Math.Abs(ts1.Ticks), Math.Abs(ts2.Ticks));
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\WebSocketHelper.cs (1)
40return Math.Max(WebSocketDefaults.MinReceiveBufferSize, effectiveMaxReceiveBufferSize);
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\WebSocketTransportDuplexSessionChannel.cs (2)
494_receiveBufferSize = Math.Min(WebSocketHelper.GetReceiveBufferSize(_maxReceivedMessageSize), _maxBufferSize); 596int newSize = (int)Math.Min(((double)internalBuffer.Length) * 2, _maxBufferSize);
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\ClientRuntime.cs (1)
333max = System.Math.Max(max, this.operations[i].ParameterInspectors.Count);
FrameworkFork\System.ServiceModel\System\ServiceModel\Dispatcher\DispatchRuntime.cs (2)
279max = System.Math.Max(max, _operations[i].ParameterInspectors.Count); 281max = System.Math.Max(max, _unhandled.ParameterInspectors.Count);
FrameworkFork\System.ServiceModel\System\ServiceModel\UdpBinding.cs (2)
33this.MaxRetransmitCount = Math.Max(transport.RetransmissionSettings.MaxUnicastRetransmitCount, transport.RetransmissionSettings.MaxMulticastRetransmitCount); 72return Math.Max(_udpTransport.RetransmissionSettings.MaxUnicastRetransmitCount, _udpTransport.RetransmissionSettings.MaxMulticastRetransmitCount);
FrameworkFork\System.ServiceModel\System\ServiceModel\XmlBuffer.cs (1)
63int initialBufferSize = Math.Min(512, maxBufferSize);
dotnet-user-jwts (1)
Helpers\ConsoleTable.cs (1)
61var equalColumnLengths = Math.Max((Console.WindowWidth / _columns.Count) - EXCESS_LENGTH_CREATED_BY_BORDERS, 5);
http2cat (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
IIS.FunctionalTests (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
IIS.LongTests (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
IIS.NewHandler.FunctionalTests (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
IIS.NewShim.FunctionalTests (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
IIS.ShadowCopy.Tests (3)
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
IISExpress.FunctionalTests (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
illink (2)
InMemory.FunctionalTests (2)
RequestTests.cs (1)
2337var mask = Math.Pow(2, lines.Length) - 1;
src\Servers\Kestrel\shared\test\StringExtensions.cs (1)
15return s.Substring(0, Math.Min(128, s.Length))
KeyManagementSimulator (2)
Program.cs (2)
194Console.WriteLine($"Instance {i}: {Math.Round(cumulativeProblemTime.TotalHours, 2)} hours"); 198Console.WriteLine($"Total missing key score (lower is better) = {Math.Round(totalProblemTime.TotalHours, 2)} hours");
LocalizationSample (4)
Startup.cs (4)
100await context.Response.WriteAsync($"<tr><th>{SR["Big number (invariant):"]}</th><td>{(Math.Pow(2, 42) + 0.42).ToString("N", CultureInfo.InvariantCulture)}</td></tr>"); 101await context.Response.WriteAsync($"<tr><th>{SR["Big number (request):"]}</th><td>{(Math.Pow(2, 42) + 0.42).ToString("N", CultureInfo.CurrentCulture)}</td></tr>"); 102await context.Response.WriteAsync($"<tr><th>{SR["Big number negative (invariant):"]}</th><td>{(-Math.Pow(2, 42) + 0.42).ToString("N", CultureInfo.InvariantCulture)}</td></tr>"); 103await context.Response.WriteAsync($"<tr><th>{SR["Big number negative (request):"]}</th><td>{(-Math.Pow(2, 42) + 0.42).ToString("N", CultureInfo.CurrentCulture)}</td></tr>");
Microsoft.Analyzers.Local.Tests (1)
InternalReferencedInPublicDocAnalyzerTests.cs (1)
43var casesCnt = Math.Max(firstList.Count, secondList.Count);
Microsoft.Arcade.Common (1)
ExponentialRetry.cs (1)
57(Math.Pow(DelayBase, i) + DelayConstant) * randomFactor);
Microsoft.Arcade.Test.Common (3)
DiffUtil.cs (3)
211int max = Math.Max(lengthA, lengthB); 263d[i, j] = Math.Min(Math.Min(m1, m2), m3);
Microsoft.AspNetCore.App.Analyzers (2)
Infrastructure\EmbeddedSyntax\EmbeddedSyntaxNode.cs (2)
102start = Math.Min(token.VirtualChars[0].Span.Start, start); 103end = Math.Max(token.VirtualChars.Last().Span.End, end);
Microsoft.AspNetCore.Authentication.Cookies (2)
src\Shared\ChunkingCookieManager\ChunkingCookieManager.cs (2)
191var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); 206var length = Math.Min(dataSizePerCookie, remainingLength);
Microsoft.AspNetCore.Authentication.OpenIdConnect (1)
OpenIdConnectHandler.cs (1)
432message.MaxAge = Convert.ToInt64(Math.Floor((maxAge.Value).TotalSeconds))
Microsoft.AspNetCore.Components (4)
src\Components\Shared\src\ArrayBuilder.cs (2)
90var candidateCapacity = Math.Max(_items.Length * 2, _minCapacity); 179var newCapacity = Math.Max(desiredCapacity, _minCapacity);
src\Http\Routing\src\Template\RoutePrecedence.cs (2)
71precedence += decimal.Divide(digit, (decimal)Math.Pow(10, i)); 127precedence += decimal.Divide(digit, (decimal)Math.Pow(10, i));
Microsoft.AspNetCore.Components.Forms (2)
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (2)
59var sizeToRent = _currentBuffer.Length + Math.Max(MinimumRentedArraySize, remainingLength * 2); 80var sizeToRent = Math.Max(MinimumRentedArraySize, remainingLength * 2);
Microsoft.AspNetCore.Components.QuickGrid (1)
QuickGrid.razor.cs (1)
340count = Math.Min(request.Count, Pagination.ItemsPerPage - request.StartIndex);
Microsoft.AspNetCore.Components.Server (11)
BlazorPack\SequenceOfT.cs (1)
223sizeHint = Math.Max(this.MinimumSpanLength, sizeHint);
Circuits\RemoteJSDataStream.cs (1)
49(int)Math.Min(signalRMaximumIncomingBytes, 50 * 1024) - 512 :
Circuits\RemoteJSRuntime.cs (1)
148_byteArraysToBeRevivedTotalBytes += Math.Max(4, data.Length);
src\Components\Shared\src\ArrayBuilder.cs (2)
90var candidateCapacity = Math.Max(_items.Length * 2, _minCapacity); 179var newCapacity = Math.Max(desiredCapacity, _minCapacity);
src\Shared\PooledArrayBufferWriter.cs (1)
157var growBy = Math.Max(sizeHint, _rentedBuffer.Length);
src\SignalR\common\Shared\BinaryMessageParser.cs (1)
36var lengthPrefixBuffer = buffer.Slice(0, Math.Min(MaxLengthPrefixSize, buffer.Length));
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\BufferWriter.cs (1)
239var writable = Math.Min(bytesLeftToCopy, _span.Length);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\MessagePackReader.cs (1)
1109int bytesRead = Math.Min(remainingByteLength, this.reader.UnreadSpan.Length);
src\submodules\MessagePack-CSharp\src\MessagePack.UnityClient\Assets\Scripts\MessagePack\SequenceReader.cs (1)
484int toCopy = Math.Min(nextSpan.Length, destination.Length - copied);
Microsoft.AspNetCore.Components.Web (14)
Forms\InputFile\BrowserFileStream.cs (1)
73var maxBytesToRead = (int)Math.Min(bytesAvailableToRead, buffer.Length);
src\Components\Shared\src\ExpressionFormatting\ReverseStringBuilder.cs (2)
59var sizeToRent = _currentBuffer.Length + Math.Max(MinimumRentedArraySize, remainingLength * 2); 80var sizeToRent = Math.Max(MinimumRentedArraySize, remainingLength * 2);
Virtualization\Virtualize.cs (11)
229var lastItemIndex = Math.Min(_itemsBefore + _visibleItemCapacity, _itemCount); 231var placeholdersBeforeCount = Math.Min(_loadedItemsStartIndex, lastItemIndex); 271_lastRenderedPlaceholderCount = Math.Max(0, lastItemIndex - _itemsBefore - _lastRenderedItemCount); 283var itemsAfter = Math.Max(0, _itemCount - _visibleItemCapacity - _itemsBefore); 320var itemsBefore = Math.Max(0, _itemCount - itemsAfter - visibleItemCapacity); 359int val => Math.Min(val, MaxItemCount), 363itemsInSpacer = Math.Max(0, (int)Math.Floor(spacerSize / _itemSize) - OverscanCount); 364visibleItemCapacity = (int)Math.Ceiling(containerSize / _itemSize) + 2 * OverscanCount; 365unusedItemCapacity = Math.Max(0, visibleItemCapacity - maxItemCount); 375itemsBefore = Math.Max(0, _itemCount - visibleItemCapacity);
Microsoft.AspNetCore.Components.WebAssembly (1)
src\Components\Shared\src\PullFromJSDataStream.cs (1)
99numBytesToRead = (int)Math.Min(numBytesToRead, _totalLength - _offset);
Microsoft.AspNetCore.Components.WebView (3)
src\Components\Shared\src\ArrayBuilder.cs (2)
90var candidateCapacity = Math.Max(_items.Length * 2, _minCapacity); 179var newCapacity = Math.Max(desiredCapacity, _minCapacity);
src\Components\Shared\src\PullFromJSDataStream.cs (1)
99numBytesToRead = (int)Math.Min(numBytesToRead, _totalLength - _offset);
Microsoft.AspNetCore.CookiePolicy.Test (2)
src\Shared\ChunkingCookieManager\ChunkingCookieManager.cs (2)
191var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); 206var length = Math.Min(dataSizePerCookie, remainingLength);
Microsoft.AspNetCore.Cryptography.KeyDerivation (1)
PBKDF2\ManagedPbkdf2Provider.cs (1)
58int numBytesToCopy = Math.Min(numBytesRemaining, T_blockIndex.Length);
Microsoft.AspNetCore.DataProtection (2)
SP800_108\ManagedSP800_108_CTR_HMACSHA512.cs (1)
47var numBytesToCopyThisIteration = Math.Min(prfOutputSizeInBytes, outputCount);
SP800_108\Win7SP800_108_CTR_HMACSHA512Provider.cs (1)
67uint numBytesToCopy = Math.Min(cbDerivedKey, SHA512_DIGEST_SIZE_IN_BYTES);
Microsoft.AspNetCore.DataProtection.Tests (1)
TypeForwardingActivatorTests.cs (1)
128new Version(Math.Max(0, current.Major - 1), 0, 0, 0),
Microsoft.AspNetCore.Diagnostics (1)
src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (1)
149var preErrorLineNumberInFile = Math.Max(errorStartLineNumberInFile - _sourceCodeLineCount, 1);
Microsoft.AspNetCore.Grpc.JsonTranscoding (1)
src\Grpc\JsonTranscoding\src\Shared\Legacy.cs (1)
229AppendNanoseconds(builder, Math.Abs(nanos));
Microsoft.AspNetCore.Grpc.Swagger (1)
src\Grpc\JsonTranscoding\src\Shared\Legacy.cs (1)
229AppendNanoseconds(builder, Math.Abs(nanos));
Microsoft.AspNetCore.Hosting (1)
src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (1)
149var preErrorLineNumberInFile = Math.Max(errorStartLineNumberInFile - _sourceCodeLineCount, 1);
Microsoft.AspNetCore.Http (3)
Internal\ReferenceReadStream.cs (2)
95var toRead = Math.Min(count, _length - _position); 108var toRead = (int)Math.Min(buffer.Length, _length - _position);
src\Http\Shared\StreamCopyOperationInternal.cs (1)
57readLength = (int)Math.Min(bytesRemaining.GetValueOrDefault(), (long)readLength);
Microsoft.AspNetCore.Http.Abstractions (5)
Routing\RouteValueDictionary.cs (2)
680capacity = Math.Max(DefaultCapacity, Math.Max(storage.Properties.Length, capacity));
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
Microsoft.AspNetCore.Http.Connections (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.Http.Connections.Tests (1)
TestWebSocketConnectionFeature.cs (1)
155length = Math.Min(buffer.Count - buffer.Offset, _internalBuffer.Buffer.Length);
Microsoft.AspNetCore.Http.Extensions (5)
src\Http\Shared\StreamCopyOperationInternal.cs (1)
57readLength = (int)Math.Min(bytesRemaining.GetValueOrDefault(), (long)readLength);
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (1)
293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2));
Microsoft.AspNetCore.Http.Results (2)
src\Http\Shared\StreamCopyOperationInternal.cs (1)
57readLength = (int)Math.Min(bytesRemaining.GetValueOrDefault(), (long)readLength);
src\Shared\RangeHelper\RangeHelper.cs (1)
121var bytes = Math.Min(end.Value, length);
Microsoft.AspNetCore.Http.Tests (1)
Features\FormFeatureTests.cs (1)
620var toWrite = Math.Min(size - written, bytes.Length);
Microsoft.AspNetCore.HttpLogging (8)
BufferingStream.cs (2)
184sizeHint = Math.Max(MinimumBufferSize, sizeHint); 186var adjustedToMaximumSize = Math.Min(maxBufferSize, sizeHint);
RequestBufferingStream.cs (1)
94var innerCount = Math.Min(remaining, span.Length);
ResponseBufferingStream.cs (1)
85var innerCount = Math.Min(remaining, span.Length);
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (1)
293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2));
Microsoft.AspNetCore.HttpOverrides (4)
ForwardedHeadersMiddleware.cs (4)
133entryCount = Math.Max(forwardedFor.Length, entryCount); 145entryCount = Math.Max(forwardedProto.Length, entryCount); 159entryCount = Math.Max(forwardedHost.Length, entryCount); 174entryCount = Math.Max(forwardedPrefix.Length, entryCount);
Microsoft.AspNetCore.HttpsPolicy (1)
HstsMiddleware.cs (1)
40var maxAge = Convert.ToInt64(Math.Floor(hstsOptions.MaxAge.TotalSeconds))
Microsoft.AspNetCore.Identity.FunctionalTests (1)
src\Identity\Extensions.Core\src\Base32.cs (1)
96var bits = Math.Min(5 - bitIndex, 8 - outputBits);
Microsoft.AspNetCore.InternalTesting (1)
xunit\AspNetTestRunner.cs (1)
80var numAttempts = Math.Max(1, retryAttribute.MaxRetries);
Microsoft.AspNetCore.Mvc.Core (3)
src\Shared\ChunkingCookieManager\ChunkingCookieManager.cs (2)
191var cookieChunkCount = (int)Math.Ceiling(value.Length * 1.0 / dataSizePerCookie); 206var length = Math.Min(dataSizePerCookie, remainingLength);
src\Shared\RangeHelper\RangeHelper.cs (1)
121var bytes = Math.Min(end.Value, length);
Microsoft.AspNetCore.Mvc.Core.TestCommon (2)
NonSeekableReadableStream.cs (2)
68count = Math.Max(count, 1); 74count = Math.Max(count, 1);
Microsoft.AspNetCore.Mvc.TagHelpers (3)
CacheTagHelper.cs (1)
264var pageLength = Math.Min(length, page.Length);
GlobbingUrlBuilder.cs (2)
202var compareLength = Math.Max(xLength, yLength); 245var length = Math.Max(xSegment.Length, ySegment.Length);
Microsoft.AspNetCore.Mvc.ViewFeatures (5)
Buffers\MemoryPoolViewBufferScope.cs (1)
58segment = _viewBufferPool.Rent(Math.Max(pageSize, MinimumSize));
Buffers\PagedBufferedTextWriter.cs (1)
57var pageLength = Math.Min(length, page.Length);
Buffers\PagedCharBuffer.cs (2)
60var copyLength = Math.Min(count, page.Length - _charIndex); 81var copyLength = Math.Min(count, page.Length - _charIndex);
src\Shared\PooledArrayBufferWriter.cs (1)
157var growBy = Math.Max(sizeHint, _rentedBuffer.Length);
Microsoft.AspNetCore.Mvc.ViewFeatures.Test (2)
DefaultHtmlGeneratorTest.cs (1)
281Assert.Equal(Math.Min(ModelWithMaxLengthMetadata.MaxLengthAttributeValue, ModelWithMaxLengthMetadata.StringLengthAttributeValue), int.Parse(attribute.Value, CultureInfo.InvariantCulture));
ViewExecutorTest.cs (1)
345var expectedWriteCallCount = Math.Ceiling((double)writeLength / TestHttpResponseStreamWriterFactory.DefaultBufferSize);
Microsoft.AspNetCore.OpenApi (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.OutputCaching (4)
FormatterBinaryWriter.cs (1)
200var toWrite = Math.Min(value.Length, available.Length);
RecyclableArrayBufferWriter.cs (2)
94int growBy = Math.Max(sizeHint, currentLength); 98growBy = Math.Max(growBy, DefaultInitialBufferSize);
RecyclableSequenceBuilder.cs (1)
100var toWrite = Math.Min(buffer.Length, available.Length);
Microsoft.AspNetCore.OutputCaching.Microbenchmarks (4)
EndToEndBenchmarks.cs (4)
83var bytes = Math.Min(rand.Next(4, 1024), value.Length); 96var bytes = Math.Min(rand.Next(4, 1024), value.Length); 98bytes = Math.Min(bytes, span.Length); 111var bytes = Math.Min(rand.Next(4, 1024), value.Length);
Microsoft.AspNetCore.ResponseCaching (1)
src\Shared\SegmentWriteStream.cs (1)
143var bytesWritten = Math.Min(buffer.Length, _segmentSize - (int)_bufferStream.Length);
Microsoft.AspNetCore.Routing (10)
ArrayBuilder.cs (2)
155nextCapacity = Math.Max(capacity + 1, MaxCoreClrArrayLength); 158nextCapacity = Math.Max(nextCapacity, minimum);
Matching\DfaMatcherBuilder.cs (2)
84maxDepth = Math.Max(maxDepth, endpoint.RoutePattern.PathSegments.Count); 560maxSegmentCount = Math.Max(maxSegmentCount, node.PathDepth);
Matching\NegotiationMatcherPolicy.cs (2)
160bestMatchIndex = Math.Max(bestMatchIndex, 0); 369result = Math.Max(result, endpointsQuality[i]);
Template\RoutePrecedence.cs (4)
50precedence += decimal.Divide(digit, (decimal)Math.Pow(10, i)); 71precedence += decimal.Divide(digit, (decimal)Math.Pow(10, i)); 104precedence += decimal.Divide(digit, (decimal)Math.Pow(10, i)); 127precedence += decimal.Divide(digit, (decimal)Math.Pow(10, i));
Microsoft.AspNetCore.Routing.Microbenchmarks (2)
Matching\JumpTableMultipleEntryBenchmark.cs (2)
158var text = guid.Substring(0, Math.Max(5, Math.Min(i, 36)));
Microsoft.AspNetCore.Server.HttpSys (1)
RequestProcessing\Response.cs (1)
317cachePolicy.SecondsToLive = (uint)Math.Min(_cacheTtl.Value.Ticks / TimeSpan.TicksPerSecond, Int32.MaxValue);
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (10)
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
Microsoft.AspNetCore.Server.IIS (5)
Core\IISHttpContext.IO.cs (1)
36var actual = Math.Min(readableBuffer.Length, memory.Length);
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
src\Shared\StackTrace\ExceptionDetails\ExceptionDetailsProvider.cs (1)
149var preErrorLineNumberInFile = Math.Max(errorStartLineNumberInFile - _sourceCodeLineCount, 1);
Microsoft.AspNetCore.Server.Kestrel.Core (30)
Internal\Http\Http1ChunkedEncodingMessageBody.cs (1)
402var actual = Math.Min(buffer.Length, _inputLength);
Internal\Http\HttpRequestStream.cs (1)
133var actual = (int)Math.Min(length, destination.Length);
Internal\Http2\Http2Connection.cs (6)
189StreamPool = new PooledStreamStack<Http2Stream>(Math.Min(InitialStreamPoolSize, http2Limits.MaxStreamsPerConnection)); 199(int)Math.Min(MaxTrackedStreams, int.MaxValue), 222internal uint MaxTrackedStreams => Math.Max(_serverSettings.MaxConcurrentStreams * 2, 100); 1022_frameWriter.UpdateMaxFrameSize((int)Math.Min(_clientSettings.MaxFrameSize, _serverSettings.MaxFrameSize)); 1049_frameWriter.UpdateMaxHeaderTableSize(Math.Min(_clientSettings.HeaderTableSize, (uint)Limits.Http2.HeaderTableSize)); 1867var copyAmount = (int)Math.Min(outputBuffer.Length, readResult.Buffer.Length);
Internal\Http2\Http2FrameWriter.cs (2)
619var currentSize = Math.Min(dataToFrame.Length, _maxFrameSize); 1057return Math.Min(bytes, _connectionWindow);
Internal\Http2\Http2OutputProducer.cs (1)
171return Math.Min(bytes, _streamWindow);
Internal\Infrastructure\HttpUtilities.cs (1)
181for (var i = 0; i < Math.Min(span.Length, maxChars); i++)
Internal\Infrastructure\PipeWriterHelpers\ConcurrentPipeWriter.cs (2)
396sizeHint = Math.Max(MinimumBufferSize, sizeHint); 398var adjustedToMaximumSize = Math.Min(maxBufferSize, sizeHint);
Internal\Infrastructure\TimeoutControl.cs (4)
114_readTimingElapsedTicks += Math.Min(timestamp - _lastTimestamp, _heartbeatIntervalTicks); 295var singleWriteTimeoutTimestamp = currentTimeUpperBound + Math.Max( 308_writeTimingTimeoutTimestamp = Math.Max(singleWriteTimeoutTimestamp, accumulatedWriteTimeoutTimestamp); 342return Math.Max(_writeTimingTimeoutTimestamp, gracePeriod);
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (2)
287int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 373int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (7)
CertificatePathWatcherTests.cs (1)
100Assert.Equal(Math.Min(dirCount, fileCount), watcher.TestGetDirectoryWatchCountUnsynchronized());
HeartbeatTests.cs (1)
86var roundedActualMs = Math.Round(actualMs / 50.0) * 50.0;
Http1\Http1ConnectionTests.cs (1)
1095var delay = (int)Math.Ceiling(timeout.TotalMilliseconds / MaxWaitLoop);
Http2\Http2FrameWriterTests.cs (1)
94sut.UpdateMaxFrameSize((int)Math.Pow(2, 24) - 1);
src\Servers\Kestrel\shared\test\StringExtensions.cs (1)
15return s.Substring(0, Math.Min(128, s.Length))
src\Shared\test\Shared.Tests\runtime\Http2\DynamicTableTest.cs (1)
172int expectedCount = Math.Min(finalMaxSize / 64, headers.Count);
src\Shared\test\Shared.Tests\runtime\Http3\QPackDecoderTest.cs (1)
343int resolvedSize = Math.Min(encoded.Length - i, chunkSize);
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (2)
SchedulerBenchmark.cs (1)
20private static readonly int IOQueueCount = Math.Min(Environment.ProcessorCount, 16);
src\Servers\Kestrel\Transport.Sockets\src\Internal\IOQueue.cs (1)
91return Math.Min(processorCount, 16);
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (1)
NamedPipeTransportOptions.cs (1)
20public int ListenerQueueCount { get; set; } = Math.Min(Environment.ProcessorCount, 16);
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (1)
Internal\IOQueue.cs (1)
91return Math.Min(processorCount, 16);
Microsoft.AspNetCore.Shared.Tests (18)
runtime\Http2\DynamicTableTest.cs (1)
172int expectedCount = Math.Min(finalMaxSize / 64, headers.Count);
runtime\Http3\QPackDecoderTest.cs (1)
343int resolvedSize = Math.Min(encoded.Length - i, chunkSize);
SegmentWriteStreamTests.cs (3)
60var expectedSegmentSize = Math.Min(segmentSize, WriteData.Length - i); 84stream.Write(WriteData, i, Math.Min(writeSize, WriteData.Length - i)); 93var expectedSegmentSize = Math.Min(segmentSize, WriteData.Length - i);
src\Shared\runtime\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\Shared\runtime\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\Shared\runtime\Http3\QPack\QPackDecoder.cs (2)
287int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 373int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
src\Shared\SegmentWriteStream.cs (1)
143var bytesWritten = Math.Min(buffer.Length, _segmentSize - (int)_bufferStream.Length);
src\Shared\ServerInfrastructure\BufferWriter.cs (1)
145var writable = Math.Min(source.Length, _span.Length);
src\Shared\ServerInfrastructure\DuplexPipeStream.cs (1)
135var count = (int)Math.Min(readableBuffer.Length, destination.Length);
src\Shared\ServerInfrastructure\MemoryPoolExtensions.cs (1)
25return Math.Min(4096, pool.MaxBufferSize);
Microsoft.AspNetCore.SignalR.Client.Core (2)
src\SignalR\common\Shared\MessageBuffer.cs (2)
373var numElements = (int)Math.Min(BufferLength, Math.Max(1, sequenceId - (linkedBuffer._startingSequenceId - 1)));
Microsoft.AspNetCore.SignalR.Client.Tests (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.SignalR.Common (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.SignalR.Common.Tests (1)
src\SignalR\common\Shared\BinaryMessageParser.cs (1)
36var lengthPrefixBuffer = buffer.Slice(0, Math.Min(MaxLengthPrefixSize, buffer.Length));
Microsoft.AspNetCore.SignalR.Core (2)
src\SignalR\common\Shared\MessageBuffer.cs (2)
373var numElements = (int)Math.Min(BufferLength, Math.Max(1, sequenceId - (linkedBuffer._startingSequenceId - 1)));
Microsoft.AspNetCore.SignalR.Microbenchmarks (1)
src\SignalR\common\Shared\BinaryMessageParser.cs (1)
36var lengthPrefixBuffer = buffer.Slice(0, Math.Min(MaxLengthPrefixSize, buffer.Length));
Microsoft.AspNetCore.SignalR.Protocols.MessagePack (2)
src\SignalR\common\Shared\BinaryMessageParser.cs (1)
36var lengthPrefixBuffer = buffer.Slice(0, Math.Min(MaxLengthPrefixSize, buffer.Length));
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
src\SignalR\common\Shared\MemoryBufferWriter.cs (1)
187_currentSegment = ArrayPool<byte>.Shared.Rent(Math.Max(_minimumSegmentSize, sizeHint));
Microsoft.AspNetCore.StaticAssets (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
121var bytes = Math.Min(end.Value, length);
Microsoft.AspNetCore.StaticFiles (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
121var bytes = Math.Min(end.Value, length);
Microsoft.AspNetCore.StaticFiles.FunctionalTests (1)
src\Shared\RangeHelper\RangeHelper.cs (1)
121var bytes = Math.Min(end.Value, length);
Microsoft.AspNetCore.TestHost (2)
ResponseBodyReaderStream.cs (1)
102var actual = Math.Min(readableBuffer.Length, buffer.Length);
TestWebSocket.cs (1)
141int count = Math.Min(buffer.Count, receiveMessage.Buffer.Count);
Microsoft.AspNetCore.WebSockets (5)
HandshakeHelpers.cs (1)
206parsedOptions.ServerMaxWindowBits = Math.Min(parsedServerMaxWindowBits ?? 15, serverMaxWindowBits);
src\Shared\ValueStringBuilder\ValueListBuilder.cs (3)
78int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 88nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\Shared\ValueStringBuilder\ValueStringBuilder.cs (1)
293char[] poolArray = ArrayPool<char>.Shared.Rent((int)Math.Max((uint)(_pos + additionalCapacityBeyondPos), (uint)_chars.Length * 2));
Microsoft.AspNetCore.WebSockets.Tests (2)
BufferStream.cs (2)
133int actualCount = Math.Min(count, _topBuffer.Count); 197var actualCount = Math.Min(count, _topBuffer.Count);
Microsoft.AspNetCore.WebUtilities (18)
BufferedReadStream.cs (2)
209int toCopy = Math.Min(_bufferCount, count); 231int toCopy = Math.Min(_bufferCount, buffer.Length);
FileBufferingReadStream.cs (3)
284var rentedBuffer = _bytePool.Rent(Math.Min((int)oldBuffer.Length, _maxRentedBufferSize)); 359var rentedBuffer = _bytePool.Rent(Math.Min((int)oldBuffer.Length, _maxRentedBufferSize)); 432bufferSize = Math.Max(4096, bufferSize);
HttpResponseStreamWriter.cs (3)
629var remaining = Math.Min(_charBufferSize - _charBufferCount, count); 644var remaining = Math.Min(_charBufferSize - _charBufferCount, count); 660var remaining = Math.Min(_charBufferSize - _charBufferCount, value.Length);
MultipartReaderStream.cs (9)
177var slice = buffer.AsSpan(offset, Math.Min(count, index)); 197read = _innerStream.Read(buffer, offset, Math.Min(count, matchOffset - bufferedData.Offset)); 208read = _innerStream.Read(buffer, offset, Math.Min(count, bufferedData.Count)); 257var slice = buffer[..Math.Min(buffer.Length, index)]; 280var slice = buffer[..Math.Min(buffer.Length, matchOffset - bufferedData.Offset)]; 294read = _innerStream.Read(buffer.Span[..Math.Min(buffer.Length, bufferedData.Count)]); 325matchOffset = Math.Max(segment1.Offset, segment1.Offset + segment1.Count - matchBytes.Length); 352bufferSize = Math.Max(4096, bufferSize); 361bufferSize = Math.Max(4096, bufferSize);
PagedByteBuffer.cs (1)
53var copyLength = Math.Min(memory.Length, currentPage.Length - _currentPageIndex);
Microsoft.AspNetCore.WebUtilities.Tests (4)
HttpResponseStreamWriterTest.cs (2)
133var expectedWriteCount = Math.Ceiling((double)byteLength / HttpResponseStreamWriter.DefaultBufferSize); 171var expectedWriteCount = Math.Ceiling((double)byteLength / HttpResponseStreamWriter.DefaultBufferSize);
NonSeekableReadStream.cs (2)
59count = Math.Max(count, 1); 65count = Math.Max(count, 1);
Microsoft.Build (53)
BackEnd\BuildManager\BuildManager.cs (1)
1932Math.Round(projectGraph.ConstructionMetrics.ConstructionTime.TotalSeconds, 3),
BackEnd\Client\MSBuildClient.cs (1)
624NodeProviderOutOfProcBase.ConnectToPipeStream(_nodeStream, _pipeName, _handshake, Math.Max(1, timeoutMilliseconds - (int)sw.ElapsedMilliseconds));
BackEnd\Components\Caching\ConfigCache.cs (2)
283remainingToRelease = Convert.ToInt32(Math.Max(1, Math.Floor(_configurations.Count * 0.1)));
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (2)
778int lengthToWrite = Math.Min(writeStreamLength - i, MaxPacketWriteSize); 856delay = Math.Min(delay * 2, 500);
BackEnd\Components\Logging\LoggingService.cs (2)
318_queueCapacity = Math.Max(0, _queueCapacity); 1874int newMinImportance = Math.Max((int)_minimumRequiredMessageImportance, (int)minimumImportance);
BackEnd\Components\RequestBuilder\TaskHost.cs (1)
874coresBeingReleased = Math.Min(coresBeingReleased, _additionalAcquiredCores);
BackEnd\Components\Scheduler\Scheduler.cs (8)
585int grantedCores = Math.Min(requestedCores, availableCores); 1303configurationCountLimit = Math.Max(1, (int)Math.Ceiling(configurationCountLimit * _customSchedulerForSQLConfigurationLimitMultiplier / _availableNodes.Count)); 1408int implicitlyGrantedCores = Math.Max(1, (_schedulingData.ExecutingRequestsCount * _nodeCoreAllocationWeight) / 100); 1413return Math.Max(0, _coreLimit - (implicitlyGrantedCores + explicitlyGrantedCores)); 1553inProcNodesToCreate = Math.Min(availableNodesWithInProcAffinity, inProcNodesToCreate); 1585outOfProcNodesToCreate = Math.Min(maxCreatableOutOfProcNodes, outOfProcNodesToCreate); 2502int postPad = Math.Max(20 /* field width */ - (2 * level) /* spacing for hierarchy lines */ - 3 /* length allocated for config/request id */, 0);
BackEnd\Components\Scheduler\SchedulingData.cs (1)
680coresToRemove = Math.Min(request.GrantedCores, coresToRemove);
BackEnd\Components\Scheduler\SchedulingPlan.cs (1)
418MaximumConfigurationId = Math.Max(MaximumConfigurationId, configId);
BuildCheck\Infrastructure\CheckWrapper.cs (1)
88CheckConfigurationEffective effectiveConfig = effectiveConfigs[Math.Max(idx, effectiveConfigs.Count - 1)];
Collections\HashTableUtility.cs (1)
44int comparison = Math.Sign(h1.Count - h2.Count);
Collections\RetrievableEntryHashSet\HashHelpers.cs (1)
41int limit = (int)Math.Sqrt(candidate);
Definition\Project.cs (2)
2977string displayValue = escapedValue.Substring(0, Math.Min(escapedValue.Length, 75)) + ((escapedValue.Length > 75) ? "..." : String.Empty); 2984string displayOriginalValue = originalValue.Substring(0, Math.Min(originalValue.Length, 75)) + ((originalValue.Length > 75) ? "..." : String.Empty);
Evaluation\Expander.cs (7)
3991else if (_receiverType == typeof(Math)) 3993if (string.Equals(_methodMethodName, nameof(Math.Max), StringComparison.OrdinalIgnoreCase)) 3997returnVal = Math.Max(arg0, arg1); 4001else if (string.Equals(_methodMethodName, nameof(Math.Min), StringComparison.OrdinalIgnoreCase)) 4005returnVal = Math.Min(arg0, arg1); 4772if (Math.Abs(arg - d) == 0) 4809if (Math.Abs(arg - d) == 0)
Evaluation\Profiler\EvaluationLocationPrettyPrinterBase.cs (2)
36return Math.Round(timeSpan.TotalMilliseconds, 0, MidpointRounding.AwayFromZero); 44return Math.Round(percentage, 1, MidpointRounding.AwayFromZero);
FileMatcher.cs (3)
999dop = Math.Min(taskOptions.MaxTasksPerIteration, taskOptions.AvailableTasks); 2537int compareLength = Math.Min( 2576var maxTasks = Math.Max(1, NativeMethodsShared.GetLogicalCoreCount() / 2);
FileUtilities.cs (1)
397var headingSegmentsToRemove = Math.Max(0, segments.Length - trailingSegmentsToKeep);
Instance\ProjectInstance.cs (2)
3233var importPaths = new List<string>(Math.Max(0, importClosure.Count - 1) /* outer project */); 3246var importPathsIncludingDuplicates = new List<string>(Math.Max(0, importClosureWithDuplicates.Count - 1) /* outer project */);
Logging\BaseConsoleLogger.cs (1)
812"{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0));
Logging\BinaryLogger\Postprocessing\StreamExtensions.cs (1)
48int read = stream.Read(buffer, 0, (int)Math.Min(bytesCount - totalRead, buffer.Length));
Logging\BinaryLogger\Postprocessing\SubStream.cs (4)
49count = Math.Min((int)Math.Max(Length - _position, 0), count); 72count = Math.Min((int)Math.Max(Length - _position, 0), count);
Logging\LogFormatter.cs (1)
53int prettyLength = System.Math.Min(11, rawTimeLength);
Logging\ParallelLogger\ConsoleOutputAligner.cs (1)
110int remainingCharsToEndOfBuffer = Math.Min(bufferWidthMinusNewLine - cursor, count - endIndex);
Logging\ParallelLogger\ParallelConsoleLogger.cs (1)
1760"{0,5}", Math.Round(elapsedTime.TotalMilliseconds, 0));
NodeEndpointOutOfProcBase.cs (1)
365int waitTimeRemaining = Math.Max(0, CommunicationsUtilities.NodeConnectionTimeout - (int)usedWaitTime.TotalMilliseconds);
Resources\Constants.cs (1)
353availableStaticMethods.TryAdd("System.Math", new Tuple<string, Type>(null, typeof(Math)));
StringExtensions.cs (1)
62int length = Math.Min(span.Length, other.Length);
StringUtils.cs (1)
24int randomBytesNeeded = (int)Math.Ceiling(length * bytesNumNeededForSingleStringChar);
Utilities\NuGetFrameworkWrapper.cs (1)
114return version.ToString(Math.Max(nonZeroVersionParts, minVersionPartCount));
Microsoft.Build.Engine.OM.UnitTests (1)
FileUtilities.cs (1)
397var headingSegmentsToRemove = Math.Max(0, segments.Length - trailingSegmentsToKeep);
Microsoft.Build.Engine.UnitTests (1)
Evaluation\SimpleVersion_Tests.cs (1)
129Assert.Equal(expectedSign, Math.Sign(version1.CompareTo(version2)));
Microsoft.Build.Framework (11)
HashHelpers.cs (1)
49var limit = (int)Math.Sqrt(candidate);
SegmentedArray.cs (10)
488var currentSegmentLength = Math.Min(remainingInSegment, _length); 497var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed); 592var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 640var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 730_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 737_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed)); 779_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 786_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
Microsoft.Build.Tasks.Core (9)
FileMatcher.cs (3)
999dop = Math.Min(taskOptions.MaxTasksPerIteration, taskOptions.AvailableTasks); 2537int compareLength = Math.Min( 2576var maxTasks = Math.Max(1, NativeMethodsShared.GetLogicalCoreCount() / 2);
FileUtilities.cs (1)
397var headingSegmentsToRemove = Math.Max(0, segments.Length - trailingSegmentsToKeep);
GenerateResource.cs (2)
736int maxCount = Math.Min(inputsToProcess.Count, outputsToProcess.Count); 737maxCount = Math.Min(maxCount, 5); // Limit to just 5
Hash.cs (1)
86int charsToProcess = Math.Min(itemSpec.Length - itemSpecPosition, MaxInputChunkLength);
StreamMappedString.cs (1)
388charactersExtracted = Math.Min(length - i, charactersOnPage - relativeStartPosition);
StringUtils.cs (1)
24int randomBytesNeeded = (int)Math.Ceiling(length * bytesNumNeededForSingleStringChar);
Microsoft.Build.Tasks.UnitTests (6)
XmlPeek_Tests.cs (2)
286for (int i = 0; i < Math.Pow(2, attrs.Length); i++) 291if ((i & (int)Math.Pow(2, k)) != 0)
XmlPoke_Tests.cs (2)
264for (int i = 0; i < Math.Pow(2, attrs.Length); i++) 269if ((i & (int)Math.Pow(2, k)) != 0)
XslTransformation_Tests.cs (2)
442for (int i = 0; i < Math.Pow(2, attrs.Length); i++) 447if ((i & (int)Math.Pow(2, k)) != 0)
Microsoft.Build.UnitTests.Shared (2)
ObjectModelHelpers.cs (2)
289int minimumLength = Math.Min(expectedItems.Length, items.Count); 1948for (int i = 0; i < Math.Min(actualLines.Length, expectedLines.Length); i++)
Microsoft.Build.Utilities.Core (4)
FileMatcher.cs (3)
999dop = Math.Min(taskOptions.MaxTasksPerIteration, taskOptions.AvailableTasks); 2537int compareLength = Math.Min( 2576var maxTasks = Math.Max(1, NativeMethodsShared.GetLogicalCoreCount() / 2);
FileUtilities.cs (1)
397var headingSegmentsToRemove = Math.Max(0, segments.Length - trailingSegmentsToKeep);
Microsoft.CodeAnalysis (111)
CaseInsensitiveComparison.cs (2)
111int len = Math.Min(str1.Length, str2.Length); 127int len = Math.Min(str1.Length, str2.Length);
CodeGen\EmitState.cs (1)
76MaxStack = Math.Max(MaxStack, CurStack);
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);
CodeGen\StateMachineStateDebugInfo.cs (2)
70firstUnusedIncreasingStateMachineState = (firstUnusedIncreasingStateMachineState != null) ? (StateMachineState)Math.Max((int)firstUnusedIncreasingStateMachineState.Value, (int)maxState) : maxState; 74firstUnusedDecreasingStateMachineState = (firstUnusedDecreasingStateMachineState != null) ? (StateMachineState)Math.Min((int)firstUnusedDecreasingStateMachineState.Value, (int)minState) : minState;
CodeGen\TokenMap.cs (1)
76Array.Resize(ref items, Math.Max(8, count * 2));
Collections\ImmutableMemoryStream.cs (1)
71int result = Math.Min(count, _array.Length - _position);
Collections\Rope.cs (1)
104wrote = Math.Min(maxLength, _value.Length);
Collections\SmallDictionary.cs (2)
191Math.Abs(a - b) >= 2) 196return 1 + Math.Max(a, b);
ConstantValueSpecialized.cs (1)
224@$"""{RopeValue.ToString(Math.Max(formatLength - 3, 0))}...""" :
Diagnostic\DiagnosticInfo.cs (1)
141expectedLength = Math.Max(value + 1, expectedLength);
Diagnostic\XmlLocation.cs (4)
30int lineNumber = Math.Max(exception.LineNumber - 1, 0); 31int columnNumber = Math.Max(exception.LinePosition - 1, 0); 42int lineNumber = Math.Max(xmlLineInfo.LineNumber - 1, 0); 43int columnNumber = Math.Max(xmlLineInfo.LinePosition - 1, 0);
DiagnosticAnalyzer\AnalyzerDriver.cs (1)
1519var workerCount = prePopulatedEventQueue ? Math.Min(CompilationEventQueue.Count, _workerCount) : _workerCount;
DiaSymReader\Metadata\SymWriterMetadataAdapter.cs (1)
111int adjustedLength = Math.Min(nameStr.Length, nameBufferLength - 1);
DiaSymReader\Utilities\ComMemoryStream.cs (5)
57bytesToCopy = Math.Min(chunk.Length, remainingBytes); 87bytesToCopy = Math.Min(chunk.Length, remainingBytes); 121int bytesToCopy = Math.Min(_length - _position, Math.Min(cb, _chunkSize - chunkOffset)); 215int bytesToCopy = Math.Min(cb, _chunkSize - chunkOffset);
DiaSymReader\Utilities\InteropUtilities.cs (2)
50*qualifiedNameLength = Math.Min(fullLength, Math.Max(0, qualifiedNameBufferLength - 1));
DiaSymReader\Writer\SymUnmanagedSequencePointsWriter.cs (1)
42int newLength = Math.Max(length, (_offsets.Length + 1) * 2);
DocumentationComments\XmlDocumentationCommentTextReader.XmlStream.cs (1)
134int charCount = Math.Min(src.Length - srcIndex, destCount);
EmbeddedText.cs (1)
319using (var writer = new StreamWriter(builder, text.Encoding, bufferSize: Math.Max(1, text.Length), leaveOpen: true))
Emit\EditAndContinueMethodDebugInformation.cs (3)
74int start = Math.Max(0, offset - maxReportedLength / 2); 75int end = Math.Min(data.Length, offset + maxReportedLength / 2); 372int syntaxOffsetBaseline = Math.Min(StateMachineStates.Min(state => state.SyntaxOffset), 0);
FileSystem\PathUtilities.cs (2)
566var maxSearchIndex = Math.Min(directoryPathParts.Length, fullPathParts.Length); 648return PathsEqual(path1, path2, Math.Max(path1.Length, path2.Length));
Hashing\XxHashShared.cs (1)
465return Math.BigMul(left, right, out lower);
InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
InternalUtilities\ReadOnlyUnmanagedMemoryStream.cs (1)
37int bytesRead = Math.Min(count, _length - _position);
InternalUtilities\WeakList.cs (1)
91return Math.Max((baseSize * 2) + 1, MinimalNonEmptySize);
MetadataReference\ModuleMetadata.cs (1)
238(int)Math.Min(unmanagedMemoryStream.Length, int.MaxValue),
PEWriter\MetadataWriter.DynamicAnalysis.cs (1)
237var writer = new BlobBuilder(1 + Math.Max(c1, c2) * 2);
PEWriter\PeWriter.cs (1)
365return path + new string('\0', Math.Max(0, minLength - Encoding.UTF8.GetByteCount(path) - 1));
RealParser.cs (3)
404uint positiveExponent = (uint)Math.Max(0, data.Exponent); 405uint integerDigitsPresent = Math.Min(positiveExponent, data.MantissaCount); 598int bottomElementIndex = Math.Max(0, topElementIndex - (64 / 8) + 1);
SourceGeneration\GeneratorDriverCache.cs (2)
55for (i = Math.Min(i, MaxCacheSize - 1); i > 0; i--) 60_cacheSize = Math.Min(MaxCacheSize, _cacheSize + 1);
SourceGeneration\Nodes\NodeStateTable.cs (2)
375var totalBuilderItems = Math.Max(previousEntry.Count, outputs.Length); 378var sharedCount = Math.Min(previousEntry.Count, outputs.Length);
src\Dependencies\Collections\Internal\HashHelpers.cs (1)
49var limit = (int)Math.Sqrt(candidate);
src\Dependencies\Collections\SegmentedArray.cs (10)
494var currentSegmentLength = Math.Min(remainingInSegment, _length); 503var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed); 598var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 646var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 736_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 743_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed)); 785_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 792_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\Dependencies\Collections\SegmentedList`1.cs (1)
544var newSegmentCount = oldSegmentCount + Math.Max(1, oldSegmentCount >> segmentGrowthShiftValue);
Syntax\InternalSyntax\SeparatedSyntaxListBuilder.cs (1)
94_builder!.AddRange(list, this.Count, Math.Min(count * 2, list.Count));
Syntax\InternalSyntax\SyntaxListBuilder.cs (1)
142Math.Max(requiredSize, currentSize * 2); // NB: Size will *at least* double.
Syntax\SeparatedSyntaxListBuilder.cs (1)
98_builder.AddRange(list, this.Count, Math.Min(count << 1, list.Count));
Syntax\SyntaxDiffer.cs (2)
310if (sim >= Math.Max(_oldNodes.Peek().FullSpan.Length, _newNodes.Peek().FullSpan.Length)) 795int maxChars = Math.Min(oldText.Length, newText.Length);
Syntax\SyntaxTreeExtensions.cs (1)
92var n = Math.Min(n1, n2);
Text\CompositeText.cs (2)
100var copyLength = Math.Min(count, segment.Length - segOffset); 158var copyLength = Math.Min(count, segment.Length - segOffset);
Text\LargeText.cs (4)
69using (var reader = new StreamReader(stream, encoding, detectEncodingFromByteOrderMarks: true, bufferSize: Math.Min(length, 4096), leaveOpen: true)) 106nextChunkSize = Math.Max(maxCharRemainingGuess - 64, 64); 168int charsToCopy = Math.Min(chunk.Length - chunkStartOffset, count); 203int charsToWrite = Math.Min(chunk.Length - chunkStartOffset, count);
Text\LargeTextWriter.cs (3)
27_bufferSize = Math.Min(LargeText.ChunkSize, length); 72var copy = Math.Min(remaining, count); 105var copy = Math.Min(remaining, count);
Text\SourceText.cs (10)
308bufferSize = Math.Min(maxBufferSize, length); 562int count = Math.Min(buffer.Length, end - offset); 640var charsToCopy = Math.Min(CharBufferSize, length - index); 725int position = Math.Max(Math.Min(span.Start, this.Length), 0); 726int length = Math.Min(span.End, this.Length) - position; 731int copyLength = Math.Min(buffer.Length, length); 1012var limit = Math.Min(_lineStarts.Count, lastLineNumber + 4); 1051var contentLength = Math.Min(length - position, buffer.Length); 1194var count = Math.Min(this.Length - position, CharBufferSize);
Text\SourceTextStream.cs (3)
41_charBuffer = new char[Math.Min(bufferSize, _source.Length)]; 127int length = Math.Min(count, preambleBytes.Length); 134int charsToRead = Math.Min(_charBuffer.Length, _source.Length - _sourceOffset);
Text\SubText.cs (4)
93int compositeStart = Math.Min(UnderlyingText.Length, UnderlyingSpan.Start + start); 94int compositeEnd = Math.Min(UnderlyingText.Length, compositeStart + length); 173var startInUnderlyingText = Math.Max(underlyingTextLine.Start, _subText.UnderlyingSpan.Start); 174var endInUnderlyingText = Math.Min(underlyingTextLine.EndIncludingLineBreak, _subText.UnderlyingSpan.End);
Text\TextChangeRangeExtensions.cs (1)
224var oldChangeLeadingDeletion = Math.Min(oldChange.Span.Length, oldChangeLeadingInsertion);
Text\TextSpan.cs (6)
102int overlapStart = Math.Max(Start, span.Start); 103int overlapEnd = Math.Min(this.End, span.End); 119int overlapStart = Math.Max(Start, span.Start); 120int overlapEnd = Math.Min(this.End, span.End); 170int intersectStart = Math.Max(Start, span.Start); 171int intersectEnd = Math.Min(this.End, span.End);
VersionHelper.cs (1)
193int build = Math.Min(ushort.MaxValue, (int)days.TotalDays);
Microsoft.CodeAnalysis.CodeStyle (83)
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderHelper.cs (1)
63fileHeaderStart = Math.Min(trivia.FullSpan.Start, fileHeaderStart);
src\Analyzers\Core\Analyzers\RemoveUnnecessaryParentheses\AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs (1)
134var textSpanEndPosition = Math.Min(parenthesizedExpressionLocation.SourceSpan.End, expressionFirstLine.Span.End);
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (2)
566var maxSearchIndex = Math.Min(directoryPathParts.Length, fullPathParts.Length); 648return PathsEqual(path1, path2, Math.Max(path1.Length, path2.Length));
src\Compilers\Core\Portable\InternalUtilities\EnumerableExtensions.cs (3)
951TSource[] chunk = new ReadOnlySpan<TSource>(source, index, Math.Min(size, source.Length - index)).ToArray(); 967int arraySize = Math.Min(size, 4); 984arraySize = (int)Math.Min((uint)size, 2 * (uint)array.Length);
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
92var n = Math.Min(n1, n2);
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
224var oldChangeLeadingDeletion = Math.Min(oldChange.Span.Length, oldChangeLeadingInsertion);
src\Dependencies\Collections\Internal\HashHelpers.cs (1)
49var limit = (int)Math.Sqrt(candidate);
src\Dependencies\Collections\SegmentedArray.cs (10)
494var currentSegmentLength = Math.Min(remainingInSegment, _length); 503var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed); 598var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 646var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 736_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 743_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed)); 785_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 792_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\Dependencies\Collections\SegmentedList`1.cs (1)
544var newSegmentCount = oldSegmentCount + Math.Max(1, oldSegmentCount >> segmentGrowthShiftValue);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\ImmutableIntervalTree`1.cs (1)
198var elementsInLastRowCappedAtMidwayPoint = Math.Min(elementsInLastIncompleteRow, elementsInLastRowIfTreeWerePerfect / 2);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\IntervalTreeAlgorithms`2.cs (2)
146var overlapStart = Math.Max(thisStart, otherStart); 147var overlapEnd = Math.Min(thisEnd, otherEnd);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\MutableIntervalTree`1.Node.cs (1)
35this.Height = 1 + Math.Max(Height(left), Height(right));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\NormalizedTextSpanCollection.cs (5)
296spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span1.End)); 307spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span2.Start)); 334spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span1.End)); 581end = Math.Max(end, span.End); 617oldEnd = Math.Max(oldEnd, newEnd);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\Common\EmbeddedSyntaxNode.cs (2)
118start = Math.Min(token.VirtualChars[0].Span.Start, start); 119end = Math.Max(token.VirtualChars.Last().Span.End, end);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\Common\EmbeddedSyntaxToken.cs (4)
82Math.Min(LeadingTrivia.Length == 0 ? int.MaxValue : LeadingTrivia[0].GetSpan().Start, 83Math.Min(VirtualChars.Length == 0 ? int.MaxValue : VirtualChars[0].Span.Start, 87Math.Max(LeadingTrivia.Length == 0 ? int.MinValue : LeadingTrivia[^1].GetSpan().End, 88Math.Max(VirtualChars.Length == 0 ? int.MinValue : VirtualChars[^1].Span.End,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\INamespaceOrTypeSymbolExtensions.cs (1)
44for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.cs (3)
127if (bestMethod is null || Math.Abs(method.Parameters.Length - parameterCount) < Math.Abs(bestMethod.Parameters.Length - parameterCount)) 500var count = extensionUsedAsInstance ? Math.Max(0, method.Parameters.Length - 1) : method.Parameters.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (2)
305Math.Min(fullSpan.Start, node.SpanStart), 306Math.Max(fullSpan.End, node.Span.End));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextSpanExtensions.cs (2)
79var startSegmentEnd = Math.Min(span.End, except.Start); 83var endSegmentStart = Math.Max(span.Start, except.End);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (2)
173return Math.Max(0, baseIndentation + (indentationLevel + delta) * _indentationSize); 178return Math.Max(0, indentationLevel + extraSpaces);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractTriviaDataFactory.FormattedWhitespace.cs (2)
23this.LineBreaks = Math.Max(0, lineBreaks); 24this.Spaces = Math.Max(0, indentation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (3)
91var numberOfSpaces = Math.Max(0, desiredIndentation); 105var numberOfSpaces = Math.Max(0, desiredIndentation); 222return Math.Max(currentIndentation + indentationDelta, 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\BaseIndentationFormattingRule.cs (2)
131=> TextSpan.FromBounds(Math.Max(_span.Start, textSpan.Start), Math.Min(_span.End, textSpan.End));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
575LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation), 577LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation), 578LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column), 587LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces), 588LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0), 595var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1)); 597return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines; 746return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (1)
249=> Math.Min(Root.EndOfFileToken.FullSpan.Start, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\Logger.LogBlock.cs (1)
17private static readonly ObjectPool<RoslynLogBlock> s_pool = new(() => new RoslynLogBlock(s_pool!), Math.Min(Environment.ProcessorCount * 8, 256));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.WordSpanEnumerator.cs (1)
72Current = TextSpan.FromBounds(Current.End, Math.Min(_nameSpan.End, nextWordSeparator));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
350var segmentLength = Math.Min(buffer.Length, spanLength - offset);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\HeaderFacts\AbstractHeaderFacts.cs (1)
97return Math.Min(afterAttributesToken.Span.Start, node.Span.End);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (1)
459var startOfNodeWithoutAttributes = Math.Min(afterAttributesToken.Span.Start, endOfNode);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\BKTree.Builder.cs (3)
132var edges = ImmutableArray.CreateBuilder<Edge>(Math.Max(0, _builderNodes.Length - 1)); 153var end = start + Math.Min(edgeCount, CompactEdgeAllocationSize); 263var end = start + Math.Min(currentNode.EdgeCount, CompactEdgeAllocationSize);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (3)
482threshold = Math.Min(threshold, targetLength); 498var jStart = Math.Max(1, i - offset); 499var jEnd = Math.Min(targetLength, i + minimumEditCount + offset);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\RoslynParallel.NetFramework.cs (1)
98rval = (rval == -1) ? schedulerMax : Math.Min(schedulerMax, rval);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SerializableBytes.cs (5)
45var count = (int)Math.Min(ChunkSize, length - i); 196var copyCount = Math.Min(Math.Min(ChunkSize - currentOffset, count), (int)(length - position)); 232var copyCount = Math.Min(chunk.Length, count); 383var writeCount = Math.Min(ChunkSize - currentOffset, countLeft);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\StringEscapeEncoder.cs (1)
21var index = prefixIndex >= 0 && prohibitIndex >= 0 ? Math.Min(prefixIndex, prohibitIndex)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\WordSimilarityChecker.cs (2)
113if (Math.Abs(_source.Length - candidateText.Length) <= _threshold) 142var lengthDifference = Math.Abs(originalText.Length - candidateText.Length);
Microsoft.CodeAnalysis.CodeStyle.Fixes (3)
src\Analyzers\Core\CodeFixes\AddExplicitCast\Fixer.cs (1)
134var parameterIndex = Math.Min(i, parameters.Length - 1);
src\Analyzers\Core\CodeFixes\AddExplicitCast\InheritanceDistanceComparer.cs (1)
72distance = Math.Min(GetInheritanceDistanceRecursive(baseType, interfaceType), distance);
src\Analyzers\Core\CodeFixes\AliasAmbiguousType\AbstractAliasAmbiguousTypeCodeFixProvider.cs (1)
90for (int i = 0, n = Math.Min(t1NameSegments.Length, t2NameSegments.Length); i < n; i++)
Microsoft.CodeAnalysis.Collections.Package (12)
Internal\HashHelpers.cs (1)
49var limit = (int)Math.Sqrt(candidate);
SegmentedArray.cs (10)
494var currentSegmentLength = Math.Min(remainingInSegment, _length); 503var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed); 598var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 646var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 736_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 743_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed)); 785_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 792_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
SegmentedList`1.cs (1)
544var newSegmentCount = oldSegmentCount + Math.Max(1, oldSegmentCount >> segmentGrowthShiftValue);
Microsoft.CodeAnalysis.CSharp (49)
Binder\Binder.cs (2)
952var lastSize = Math.Min(last.Length, 12); 953snippet = first.Substring(0, Math.Min(first.Length, 12)) + " ... " + last.Substring(last.Length - lastSize, lastSize);
Binder\Binder_Deconstruct.cs (1)
351var matchCount = Math.Min(variables.Count, foundTypes.Length);
Binder\Binder_Expressions.cs (1)
4378int?[] knownSizes = new int?[Math.Max(rank, numSizes)];
Binder\DecisionDagBuilder.cs (2)
536int count = Math.Min(method.ParameterCount - extensionExtra, recursive.Deconstruction.Length); 557int count = Math.Min(elementTypes.Length, recursive.Deconstruction.Length);
Binder\Semantics\OverloadResolution\MethodTypeInference.cs (1)
164private int NumberArgumentsToProcess => System.Math.Min(_arguments.Length, _formalParameterTypes.Length);
BoundTree\UnboundLambda.cs (2)
919var numParametersToCheck = Math.Min(targetParameterTypes.Length, ParameterCount); 1401for (int i = 0, n = Math.Min(nx, ny); i < n; i++)
CodeGen\EmitArrayInitializer.cs (1)
282int thresholdCnt = Math.Max(3, (initCount / 3));
CodeGen\EmitStackAllocInitializer.cs (1)
151int thresholdCnt = Math.Max(3, (initCount / 3));
Compilation\CSharpSemanticModel.cs (1)
1293return Math.Max(token.SpanStart, fullStart);
Compiler\DocumentationCommentCompiler.cs (1)
1049int minLength = Math.Min(str1.Length, str2.Length);
Emitter\EditAndContinue\CSharpDefinitionMap.cs (1)
153int slotCount = Math.Min(localSlots.Length, slotMetadata.Length);
FlowAnalysis\NullableWalker.cs (3)
8530Debug.Assert(values.Length == (useRestField ? Math.Min(tupleType.TupleElements.Length, NamedTypeSymbol.ValueTupleRestPosition) : tupleType.TupleElements.Length)); 8538n = Math.Min(n, NamedTypeSymbol.ValueTupleRestPosition - 1); 12635int n = Math.Min(Capacity, 8);
FlowAnalysis\NullableWalker_Patterns.cs (1)
199for (int i = 0, n = Math.Min(rp.Deconstruction.Length, elements.IsDefault ? 0 : elements.Length); i < n; i++)
Lowering\LocalRewriter\LocalRewriter.DecisionDagRewriter.ValueDispatchNode.cs (5)
109Debug.Assert(Math.Abs(l - r) <= 1); 113_height = Math.Max(l, r) + 1; 117Debug.Assert(_height < 2 * Math.Log(_weight)); 162Debug.Assert(Math.Abs(left.Height - right.Height) <= 2); 251Debug.Assert(Math.Abs(left.Height - right.Height) < 2);
Lowering\StateMachineRewriter\ResumableStateMachineStateAllocator.cs (1)
78=> _matchedStateCount < Math.Abs((_slotAllocator?.GetFirstUnusedStateMachineState(_increasing) ?? _firstState) - _firstState);
Parser\Blender.cs (4)
125var start = Math.Max(Math.Min(changeRange.Span.Start, lastCharIndex), 0); 136start = Math.Max(0, token.Position - 1); 152start = Math.Max(start - column, 0);
Parser\LanguageParser_InterpolatedString.cs (2)
222currentIndex = Math.Min(currentIndex, lineStartPosition + indentationWhitespace.Length); 299for (int i = 0, n = Math.Min(currentLineWhitespace.Length, indentationLineWhitespace.Length); i < n; i++)
Parser\Lexer_RawStringLiteral.cs (2)
371_builder.Append(currentLineWhitespace, startIndex: indentationWhitespace.Length, count: Math.Max(0, currentLineWhitespace.Length - indentationWhitespace.Length)); 396for (int i = 0, n = Math.Min(currentLineWhitespace.Length, indentationLineWhitespace.Length); i < n; i++)
Parser\QuickScanner.cs (1)
198n = Math.Min(n, i + MaxCachedTokenSize);
Parser\SlidingTextWindow.cs (3)
183int amountToRead = Math.Min(_text.Length, position + _characterWindow.Length) - position; 184amountToRead = Math.Max(amountToRead, 0); 231int amountToRead = Math.Min(_textEnd - (_basis + _characterWindowCount),
Parser\SyntaxParser.cs (1)
141var size = Math.Min(CachedTokenArraySize, this.lexer.TextWindow.Text.Length / 2);
Symbols\AnonymousTypes\SynthesizedSymbols\AnonymousType.TemplateSymbol.cs (1)
192int displayCount = Math.Min(this.Properties.Length, 10);
Symbols\Tuples\TupleTypeSymbol.cs (1)
801int fieldsPerType = Math.Min(arity, ValueTupleRestPosition - 1);
Syntax\SyntaxNodeRemover.cs (2)
76start = Math.Min(start, span.Start); 77end = Math.Max(end, span.End);
Syntax\SyntaxNormalizer.cs (1)
148count = Math.Max(count - _initialDepth, 0);
Syntax\SyntaxReplacer.cs (2)
148start = Math.Min(start, span.Start); 149end = Math.Max(end, span.End);
Syntax\SyntaxTreeDiagnosticEnumerator.cs (2)
63var spanStart = Math.Min(_position - leadingWidthAlreadyCounted + sdi.Offset, length); 64var spanWidth = Math.Min(spanStart + sdi.Width, length) - spanStart;
Utilities\ValueSetFactory.IntTC.cs (1)
75return Math.Abs((random.Next() << 10) ^ random.Next());
Utilities\ValueSetFactory.NonNegativeIntValueSetFactory.cs (2)
41return new NumericValueSet<int>(Math.Max(0, value + 1), int.MaxValue, tc); 43return new NumericValueSet<int>(Math.Max(0, value), int.MaxValue, tc);
Microsoft.CodeAnalysis.CSharp.CodeStyle (7)
src\Analyzers\CSharp\Analyzers\UsePatternMatching\UsePatternMatchingHelpers.cs (1)
78requiredLanguageVersion = (LanguageVersion)Math.Max((int)requiredLanguageVersion, (int)LanguageVersion.CSharp9);
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
199var length = Math.Min(arrayCreationElements.Length - startIndex, 4);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.FormattedComplexTrivia.cs (2)
36this.LineBreaks = Math.Max(0, lineBreaks); 37this.Spaces = Math.Max(0, spaces);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (2)
165var line = Math.Max(LineBreaksAfter(previousToken, currentToken), operation.Line); 301return CreateAdjustSpacesOperation(Math.Max(0, operation.Space), AdjustSpacesOption.ForceSpaces);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
721position = Math.Min(position, end - 1);
Microsoft.CodeAnalysis.CSharp.CodeStyle.Fixes (2)
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
205using var _ = ArrayBuilder<TextChange>.GetInstance(Math.Max(0, closeBraceLine - openBraceLine - 1), out var changes);
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
71var minimalAccessibility = (Accessibility)Math.Min((int)propertySymbol.DeclaredAccessibility, (int)setMethod.DeclaredAccessibility);
Microsoft.CodeAnalysis.CSharp.EditorFeatures (10)
InlineRename\CSharpEditorInlineRenameService.cs (6)
123var fallbackStartLine = Math.Max(0, documentText.Lines.GetLineFromPosition(fallbackSpan.Start).LineNumber - NumberOfContextLines); 124var fallbackEndLine = Math.Min(documentText.Lines.Count - 1, documentText.Lines.GetLineFromPosition(fallbackSpan.End).LineNumber + NumberOfContextLines); 130endLine = Math.Min(documentText.Lines.Count - 1, fallbackEndLine + excessAtStart); 135startLine = Math.Max(0, fallbackStartLine - excessAtEnd); 151startLine = Math.Max(0, documentText.Lines.GetLineFromPosition(fallbackSpan.Start).LineNumber - NumberOfContextLines); 152endLine = Math.Min(documentText.Lines.Count - 1, documentText.Lines.GetLineFromPosition(fallbackSpan.End).LineNumber + NumberOfContextLines);
StringCopyPaste\AbstractPasteProcessor.cs (1)
162ts => Math.Max(
StringCopyPaste\KnownSourcePasteProcessor.cs (1)
247dollarSignCount = Math.Max(1, dollarSignCount);
StringCopyPaste\StringCopyPasteHelpers.cs (2)
208longestCount = Math.Max(longestCount, endQuoteIndex - currentIndex); 530for (var n = Math.Min(commonIndentPrefix.Length, lineWhitespaceSpan.Length); commonPrefixLength < n; commonPrefixLength++)
Microsoft.CodeAnalysis.CSharp.Emit.UnitTests (3)
Emit\CompilationEmitTests.cs (3)
3883for (int i = 0; i < System.Math.Max(expectedGlobalMembers.Length, actualGlobalMembers.Length); i++) 3905for (int i = 0; i < System.Math.Max(expectedAMembers.Length, actualAMembers.Length); i++) 3913for (int i = 0; i < System.Math.Max(expectedBMembers.Length, actualBMembers.Length); i++)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (2)
Semantics\PatternMatchingTests.cs (2)
4908int dt = (int)Math.Abs(DateTime.Now.Ticks % 1000000000); 4921int dt = (int)Math.Abs(DateTime.Now.Ticks % 1000000000);
Microsoft.CodeAnalysis.CSharp.EndToEnd.UnitTests (1)
EndToEndTests.cs (1)
718var interfacesNumber = Math.Max(overloads1Number, overloads2Number);
Microsoft.CodeAnalysis.CSharp.Features (27)
BraceCompletion\AbstractCurlyBraceOrBracketCompletionService.cs (1)
253var spanToFormat = TextSpan.FromBounds(Math.Max(startPoint, 0), endPoint);
ChangeSignature\ChangeSignatureFormattingRule.cs (1)
46span = TextSpan.FromBounds(Math.Max(baseToken.Span.End, span.Start), span.End);
ChangeSignature\CSharpChangeSignatureService.cs (1)
121var token = root.FindToken(position != tree.Length ? position : Math.Max(0, position - 1));
ConvertToRawString\ConvertInterpolatedStringToRawStringCodeRefactoringProvider.cs (4)
406var quoteDelimiterCount = Math.Max(3, longestQuoteSequence + 1); 426longestQuoteSequence = Math.Max(longestQuoteSequence, GetLongestQuoteSequence(characters)); 427longestBraceSequence = Math.Max(longestBraceSequence, GetLongestBraceSequence(characters)); 681var length = Math.Min(leadingWhitespace1.Length, leadingWhitespace2.Length);
ConvertToRawString\ConvertRegularStringToRawStringCodeRefactoringProvider.cs (3)
184var quoteDelimiterCount = Math.Max(3, longestQuoteSequence + 1); 211var quoteDelimiterCount = Math.Max(3, longestQuoteSequence + 1); 323var length = Math.Min(leadingWhitespace1.Length, leadingWhitespace2.Length);
ConvertToRawString\ConvertToRawStringHelpers.cs (2)
136=> Math.Max(GetLongestCharacterSequence(characters, '{'), GetLongestCharacterSequence(characters, '}')); 147longestSequence = Math.Max(longestSequence, j - i);
EditAndContinue\SyntaxComparer.cs (2)
1606oldToken.Text, Math.Min(oldToken.Text.Length, LongestCommonSubsequence.MaxSequenceLengthForDistanceCalculation), 1607newToken.Text, Math.Min(newToken.Text.Length, LongestCommonSubsequence.MaxSequenceLengthForDistanceCalculation));
EmbeddedLanguages\CSharpTestEmbeddedLanguageClassifier.cs (2)
166nestedAnonymousSpanCount = Math.Max(0, nestedAnonymousSpanCount - 1); 172nestedNamedSpanCount = Math.Max(0, nestedNamedSpanCount - 1);
ExtractMethod\CSharpSelectionValidator.cs (2)
447? Math.Min(selectionInfo.FirstTokenInOriginalSpan.SpanStart, selectionInfo.OriginalSpan.Start) 451? Math.Max(selectionInfo.LastTokenInOriginalSpan.Span.End, selectionInfo.OriginalSpan.End)
ImplementInterface\CSharpImplementExplicitlyCodeRefactoringProvider.cs (1)
157for (int i = 0, n = Math.Max(implParameters.Length, interfaceParameters.Length); i < n; i++)
IntroduceVariable\CSharpIntroduceVariableService_IntroduceField.cs (2)
115index = Math.Min(index, firstChangeIndex); 154index = Math.Min(index, firstChangeIndex);
IntroduceVariable\CSharpIntroduceVariableService_IntroduceLocal.cs (1)
460return Math.Min(earliestLocalFunctionCallIndex, firstStatementAffectedIndex);
QuickInfo\CSharpSemanticQuickInfoProvider.cs (1)
203return sourceText.GetSubText(new Text.TextSpan(span.Start, Math.Min(maxLength, span.Length))).ToString();
src\Analyzers\CSharp\Analyzers\UsePatternMatching\UsePatternMatchingHelpers.cs (1)
78requiredLanguageVersion = (LanguageVersion)Math.Max((int)requiredLanguageVersion, (int)LanguageVersion.CSharp9);
src\Analyzers\CSharp\Analyzers\UseUtf8StringLiteral\UseUtf8StringLiteralDiagnosticAnalyzer.cs (1)
199var length = Math.Min(arrayCreationElements.Length - startIndex, 4);
src\Analyzers\CSharp\CodeFixes\ConvertNamespace\ConvertNamespaceTransform.cs (1)
205using var _ = ArrayBuilder<TextChange>.GetInstance(Math.Max(0, closeBraceLine - openBraceLine - 1), out var changes);
src\Analyzers\CSharp\CodeFixes\MakeMemberRequired\CSharpMakeMemberRequiredCodeFixProvider.cs (1)
71var minimalAccessibility = (Accessibility)Math.Min((int)propertySymbol.DeclaredAccessibility, (int)setMethod.DeclaredAccessibility);
Microsoft.CodeAnalysis.CSharp.Features.UnitTests (8)
EditAndContinue\SyntaxComparerTests.cs (8)
96Assert.Equal(0.67, Math.Round(distance, 2)); 106Assert.Equal(0.33, Math.Round(distance, 2)); 113Assert.Equal(0.33, Math.Round(distance, 2)); 120Assert.Equal(1, Math.Round(distance, 2)); 130Assert.Equal(0, Math.Round(distance, 2)); 136Assert.Equal(0, Math.Round(distance, 2)); 142Assert.Equal(0, Math.Round(distance, 2)); 148Assert.Equal(0, Math.Round(distance, 2));
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (2)
Semantics\ConstantTests.cs (2)
4019floatConst = ConstantValue.Create(Math.Round(1f / 3f, 5)), 4020doubleConst = ConstantValue.Create(Math.Round((double)1 / 3, 8)),
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (5)
Symbols\CompilationCreationTests.cs (4)
51Assert.Equal(Math.Sign(compilation.CompareSyntaxTreeOrdering(expectedSyntaxTrees[i], expectedSyntaxTrees[j])), Math.Sign(i.CompareTo(j))); 60Assert.Equal(Math.Sign(compilation.CompareSourceLocations(types[i].Locations[0], types[j].Locations[0])), Math.Sign(i.CompareTo(j)));
Symbols\Source\CompletionTests.cs (1)
123Parallel.For(0, Math.Max(1, Environment.ProcessorCount - 1), t =>
Microsoft.CodeAnalysis.CSharp.Syntax.UnitTests (1)
Diagnostics\LineSpanDirectiveTests.cs (1)
501return Math.Min(line.Start + position.Character, line.End);
Microsoft.CodeAnalysis.CSharp.Test.Utilities (1)
Extensions.cs (1)
103for (int i = 0; i < Math.Max(thisRefs.Length, thatRefs.Length); i++)
Microsoft.CodeAnalysis.CSharp.Workspaces (7)
Formatting\CSharpSyntaxFormattingService.cs (2)
47var token = documentSyntax.Root.FindToken(Math.Max(0, caretPosition - 1), findInsideTrivia: true); 80var token = root.FindToken(Math.Max(0, caretPosition - 1), findInsideTrivia: true);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Engine\Trivia\TriviaDataFactory.FormattedComplexTrivia.cs (2)
36this.LineBreaks = Math.Max(0, lineBreaks); 37this.Spaces = Math.Max(0, spaces);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Formatting\Rules\ElasticTriviaFormattingRule.cs (2)
165var line = Math.Max(LineBreaksAfter(previousToken, currentToken), operation.Line); 301return CreateAdjustSpacesOperation(Math.Max(0, operation.Space), AdjustSpacesOption.ForceSpaces);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\CSharp\Services\SyntaxFacts\CSharpSyntaxFacts.cs (1)
721position = Math.Min(position, end - 1);
Microsoft.CodeAnalysis.EditorFeatures (7)
CommentSelection\AbstractCommentSelectionBase.cs (1)
214indentToCommentAt = Math.Min(indentToCommentAt, firstNonWhitespaceOnLine);
Shared\Extensions\IProjectionBufferFactoryServiceExtensions.cs (3)
90var finalSpanStart = Math.Max(line.Start, span.Start); 91var finalSpanEnd = Math.Min(line.EndIncludingLineBreak, span.End); 158? Math.Min(indentationColumn.Value, line.GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(editorOptions))
Shared\Utilities\CommonFormattingHelpers.cs (1)
38var previousLine = snapshot.GetLineFromLineNumber(Math.Max(currentLine.LineNumber - 1, 0));
Tagging\AsynchronousViewportTaggerProvider.SingleViewportTaggerProvider.cs (2)
88startLine = Math.Max(startLine - extraLines, 0); 89endLine = Math.Min(endLine + extraLines, snapshot.LineCount - 1);
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (2)
Classification\ClassificationTestHelper.cs (1)
39var max = Math.Max(expectedClassificationList.Count, actualClassificationList.Count);
KeywordHighlighting\AbstractKeywordHighlighterTests.cs (1)
70for (var j = 0; j < Math.Max(highlightSpans.Count, expectedHighlightSpans.Count); j++)
Microsoft.CodeAnalysis.EditorFeatures.UnitTests (2)
EmbeddedLanguages\StackFrame\StackFrameParserTests.Utilities.cs (2)
119var start = Math.Max(0, index - 10); 120var end = Math.Min(index, originalText.Length - 1);
Microsoft.CodeAnalysis.EditorFeatures.Wpf (11)
InlineDiagnostics\AbstractDiagnosticsTaggerProvider.cs (5)
125var length = Math.Min(Math.Max(span.Length, minimumLength), maximumLength); 128var start = Math.Max(0, Math.Min(span.Start, snapshot.Length - length)); 131return new SnapshotSpan(snapshot, start, Math.Min(start + length, snapshot.Length) - start);
InlineDiagnostics\InlineDiagnosticsAdornmentManager.cs (1)
173? Math.Max(lineView.Right, lineView.LineTransform.Right)
InlineDiagnostics\InlineDiagnosticsTag.cs (1)
84var lineHeight = Math.Floor(format.Typeface.FontFamily.LineSpacing * block.FontSize);
IWpfDifferenceViewerExtensions.cs (1)
113_width = Math.Max(textView.MaxTextRightCoordinate * (textView.ZoomLevel / 100), _minWidth); // Width of the widest line.
SignatureHelp\Controller.cs (2)
99Math.Max(Math.Min(triggerSpan.End, GetCaretPointInViewBuffer().Position), triggerSpan.Start)));
StringIndentation\StringIndentationAdornmentManager.VisibleBlock.cs (1)
61var x = Math.Floor(bounds.Right - (anchorPointLine.VirtualSpaceWidth / 2));
Microsoft.CodeAnalysis.ExpressionEvaluator.ExpressionCompiler (8)
MethodContextReuseConstraints.cs (4)
74_endOffsetExclusive = Math.Min(_endOffsetExclusive, scope.StartOffset); 78_startOffset = Math.Max(_startOffset, scope.EndOffsetExclusive); 82_startOffset = Math.Max(_startOffset, scope.StartOffset); 83_endOffsetExclusive = Math.Min(_endOffsetExclusive, scope.EndOffsetExclusive);
PDB\MethodDebugInfo.Portable.cs (4)
155reuseSpanEnd = Math.Min(reuseSpanEnd, (uint)scope.StartOffset); 162reuseSpanStart = Math.Max(reuseSpanStart, (uint)scope.EndOffset); 167reuseSpanStart = Math.Max(reuseSpanStart, (uint)scope.StartOffset); 168reuseSpanEnd = Math.Min(reuseSpanEnd, (uint)scope.EndOffset);
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider (8)
src\Compilers\Core\Portable\CaseInsensitiveComparison.cs (2)
111int len = Math.Min(str1.Length, str2.Length); 127int len = Math.Min(str1.Length, str2.Length);
src\ExpressionEvaluator\Core\Source\ResultProvider\Expansion\Expansion.cs (3)
54startIndex3 = Math.Max(startIndex1, startIndex2); 55int endIndex3 = Math.Min(startIndex1 + count1, startIndex2 + count2); 56count3 = Math.Max(endIndex3 - startIndex3, 0);
src\ExpressionEvaluator\Core\Source\ResultProvider\Expansion\TupleExpansion.cs (1)
283int n = Math.Min(cardinality, TypeHelpers.TupleFieldRestPosition - 1);
src\ExpressionEvaluator\Core\Source\ResultProvider\Formatter.TypeNames.cs (1)
405int nFields = Math.Min(nTypeArgs, TypeHelpers.TupleFieldRestPosition - 1);
src\ExpressionEvaluator\Core\Source\ResultProvider\Helpers\TypeHelpers.cs (1)
493int n = Math.Min(cardinality, TupleFieldRestPosition - 1);
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.Utilities (6)
src\ExpressionEvaluator\Core\Source\ResultProvider\Expansion\Expansion.cs (3)
54startIndex3 = Math.Max(startIndex1, startIndex2); 55int endIndex3 = Math.Min(startIndex1 + count1, startIndex2 + count2); 56count3 = Math.Max(endIndex3 - startIndex3, 0);
src\ExpressionEvaluator\Core\Source\ResultProvider\Expansion\TupleExpansion.cs (1)
283int n = Math.Min(cardinality, TypeHelpers.TupleFieldRestPosition - 1);
src\ExpressionEvaluator\Core\Source\ResultProvider\Formatter.TypeNames.cs (1)
405int nFields = Math.Min(nTypeArgs, TypeHelpers.TupleFieldRestPosition - 1);
src\ExpressionEvaluator\Core\Source\ResultProvider\Helpers\TypeHelpers.cs (1)
493int n = Math.Min(cardinality, TupleFieldRestPosition - 1);
Microsoft.CodeAnalysis.Features (29)
ClassifiedSpansAndHighlightSpanFactory.cs (1)
53return TextSpan.FromBounds(Math.Min(firstNonWhitespacePosition, referenceSpan.Start), sourceLine.End);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.cs (1)
282var spanEnd = Math.Max(startToken.Span.End, span.End);
CodeFixes\Suppression\AbstractSuppressionCodeFixProvider.RemoveSuppressionCodeAction_Pragma.cs (1)
209start: Math.Max(0, trivia.Span.Start - 1),
CodeLens\CodeLensReferencesService.cs (1)
95? Math.Min(progress.ReferencesCount, progress.SearchCap)
Completion\Providers\Scripting\AbstractDirectivePathCompletionProvider.cs (2)
122var startIndex = Math.Max(afterLastSlashIndex, afterFirstQuote); 145position = Math.Min(position, text.Length - 1);
EditAndContinue\AbstractEditAndContinueAnalyzer.cs (2)
723lineText = text.ToString(TextSpan.FromBounds(diagnostic.Span.Start, Math.Min(diagnostic.Span.Start + 120, line.End))); 1851if (areSimilar != null && matchCount < Math.Min(oldNodes.Count, newNodes.Count))
EditAndContinue\EditSession.cs (1)
217for (var i = 0; i < Math.Min(oldLineCount, newLineCount); i++)
ExternalAccess\UnitTesting\SolutionCrawler\UnitTestingIdleProcessor.cs (1)
105var delayTimeSpan = TimeSpan.FromMilliseconds(Math.Max(s_minimumDelay.TotalMilliseconds, timeLeft.TotalMilliseconds));
ExternalAccess\VSTypeScript\VSTypeScriptTaskListService.cs (2)
40var textSpan = new TextSpan(Math.Min(text.Length, Math.Max(0, d.Position)), 0);
IntroduceUsingStatement\AbstractIntroduceUsingStatementCodeRefactoringProvider.cs (1)
420endOfUsingStatementIndex = Math.Max(endOfUsingStatementIndex, lastVariableUsageIndex[localSymbol]);
NavigateTo\RoslynNavigateToItem.cs (1)
263var maxCommon = Math.Min(activeFolders.Count, itemFolders.Count);
QuickInfo\IndentationHelper.cs (3)
61var spanBeforeDeletion = TextSpan.FromBounds(span.Start, Math.Min(span.End, deletion.Start)); 70span = TextSpan.FromBounds(Math.Min(deletion.End, span.End), span.End); 125? Math.Min(currentValue, line.GetColumnOfFirstNonWhitespaceCharacterOrEndOfLine(tabSize))
RelatedDocuments\AbstractRelatedDocumentsService.cs (1)
97IteratePotentialTypeNodes(root).OrderBy(t => Math.Abs(t.expression.SpanStart - position)),
SemanticSearch\AbstractSemanticSearchService.cs (1)
291skippedFrameCount = Math.Max(0, displayFramesEnd - StackDisplayDepthLimit);
Snippets\RoslynLSPSnippetConverter.cs (5)
134startPosition = Math.Min(startPosition, placeholders.Min(placeholder => placeholder.StartingPositions.Min())); 135endPosition = Math.Max(endPosition, placeholders.Max(placeholder => placeholder.StartingPositions.Max())); 138startPosition = Math.Min(startPosition, caretPosition); 139endPosition = Math.Max(endPosition, caretPosition); 141startPosition = Math.Min(startPosition, triggerLocation);
src\Analyzers\Core\Analyzers\FileHeaders\AbstractFileHeaderHelper.cs (1)
63fileHeaderStart = Math.Min(trivia.FullSpan.Start, fileHeaderStart);
src\Analyzers\Core\Analyzers\RemoveUnnecessaryParentheses\AbstractRemoveUnnecessaryParenthesesDiagnosticAnalyzer.cs (1)
134var textSpanEndPosition = Math.Min(parenthesizedExpressionLocation.SourceSpan.End, expressionFirstLine.Span.End);
src\Analyzers\Core\CodeFixes\AddExplicitCast\Fixer.cs (1)
134var parameterIndex = Math.Min(i, parameters.Length - 1);
src\Analyzers\Core\CodeFixes\AddExplicitCast\InheritanceDistanceComparer.cs (1)
72distance = Math.Min(GetInheritanceDistanceRecursive(baseType, interfaceType), distance);
src\Analyzers\Core\CodeFixes\AliasAmbiguousType\AbstractAliasAmbiguousTypeCodeFixProvider.cs (1)
90for (int i = 0, n = Math.Min(t1NameSegments.Length, t2NameSegments.Length); i < n; i++)
Microsoft.CodeAnalysis.Features.Test.Utilities (1)
EditAndContinue\ActiveStatementsDescription.cs (1)
53var activeStatementCount = Math.Max(OldStatements.Length, (newActiveStatementMarkers.Length == 0) ? -1 : newActiveStatementMarkers.Max(m => m.Id));
Microsoft.CodeAnalysis.InteractiveHost (4)
Interactive\Core\InteractiveHost.Service.cs (1)
777for (int i = 0, n = Math.Min(diagnostics.Length, MaxErrorCount); i < n; i++)
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (2)
566var maxSearchIndex = Math.Min(directoryPathParts.Length, fullPathParts.Length); 648return PathsEqual(path1, path2, Math.Max(path1.Length, path2.Length));
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
Microsoft.CodeAnalysis.LanguageServer.Protocol (12)
Extensions\ProtocolConversions.cs (2)
504Math.Min(text.Length, span.Start), 505Math.Min(text.Length, span.End));
Features\Diagnostics\DocumentAnalysisExecutor.cs (2)
333return TextSpan.FromBounds(Math.Min(startSpan.Start, endSpan.Start), Math.Max(startSpan.End, endSpan.End));
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer.IncrementalMemberEditAnalyzer.cs (1)
387var start = Math.Max(diagnosticSpan.Start + delta, 0);
Features\Diagnostics\EngineV2\DiagnosticIncrementalAnalyzer.StateManager.HostStates.cs (2)
162DocumentDiagnosticAnalyzer analyzer => Math.Max(0, analyzer.Priority), 163ProjectDiagnosticAnalyzer analyzer => Math.Max(0, analyzer.Priority),
Features\UnifiedSuggestions\UnifiedSuggestedActionSetComparer.cs (2)
46var startsDistance = Math.Abs(a.Start - b.Start); 47var endsDistance = Math.Abs(a.End - b.End);
Handler\OnAutoInsert\OnAutoInsertHandler.cs (1)
191desiredCaretLinePosition = new LinePosition(desiredCaretLinePosition.Line, Math.Min(desiredCaretLinePosition.Character, caretLine.End));
Handler\SemanticTokens\SemanticTokensHelpers.cs (1)
199textSpan = TextSpan.FromBounds(Math.Min(absoluteStart, line.End), line.End);
Handler\SpellCheck\AbstractSpellCheckingHandler.cs (1)
178var batchEnd = Math.Min(batchStart + chunkSize, spans.Length);
Microsoft.CodeAnalysis.Remote.ServiceHub (3)
Services\DiagnosticAnalyzer\PerformanceQueue.cs (3)
120var stddev = Math.Sqrt(data.Select(ms => Math.Pow(ms - average, 2)).Average()); 121var squareLength = Math.Sqrt(data.Count);
Microsoft.CodeAnalysis.Scripting (7)
Hosting\ObjectFormatter\CommonObjectFormatter.Builder.cs (5)
32_currentLimit = Math.Min(_options.MaximumLineLength, _options.MaximumOutputLength); 55_currentLimit = (int)Math.Min((long)_sb.Length + _options.MaximumLineLength, _options.MaximumOutputLength); 81int length = Math.Min(count, CurrentRemaining); 98count = Math.Min(count, str.Length - start); 99int length = Math.Min(count, CurrentRemaining);
Hosting\ObjectFormatter\CommonObjectFormatter.Visitor.cs (1)
62return new Builder(_builderOptions.WithMaximumOutputLength(Math.Min(_builderOptions.MaximumLineLength, limit)), suppressEllipsis: true);
ScriptExecutionState.cs (1)
162Array.Resize(ref _submissionStates, Math.Max(SubmissionStateCount, _submissionStates.Length * 2));
Microsoft.CodeAnalysis.Test.Utilities (10)
Assert\AssertEx.cs (3)
456rows[nextRow][j] = Math.Min(dist1, Math.Min(dist2, dist3)); 794var expectedString = join(itemSeparator, expected[..Math.Min(expected.Length, maxDisplayedExpectedEntries)], itemInspector);
Assert\DiffUtil.cs (3)
214int max = Math.Max(lengthA, lengthB); 266d[i, j] = Math.Min(Math.Min(m1, m2), m3);
FX\CappedStringWriter.cs (1)
33_remaining = Math.Max(256, expectedLength * 4);
FX\ImmutableArrayTestExtensions.cs (2)
38var buffer = new byte[Math.Min(bufferSize, bytes.Length)]; 43int length = Math.Min(bufferSize, bytes.Length - offset);
Syntax\TokenUtilities.cs (1)
23var max = Math.Min(expectedTokens.Count, actualTokens.Count);
Microsoft.CodeAnalysis.UnitTests (21)
Collections\BitArrayTests.cs (2)
124var maxCapacity = Math.Max(capacity1, capacity2); 282capacity = Math.Max(capacity, index + 1);
Collections\EnumerableExtensionsTests.cs (2)
48public bool Equals(int x, int y) => Math.Abs(x) == Math.Abs(y);
Collections\HashSet\SegmentedHashSet_Generic_Tests`1.cs (1)
49int root = (int)Math.Sqrt(i);
Collections\HashSet\TestingTypes.cs (5)
158return Math.Abs(x) - Math.Abs(y); 163return Math.Abs(x) == Math.Abs(y); 168return Math.Abs(x);
Collections\ImmutableArrayExtensionsTests.cs (3)
130return Math.Abs(x) == Math.Abs(y); 135return Math.Abs(x);
Collections\TopologicalSortTests.cs (1)
145successors[possibleSort[i]] = randomSubset((int)Math.Sqrt(i), i);
LinePositionTests.cs (4)
80Assert.Equal(-1, Math.Sign(new LinePosition(1, 1).CompareTo(new LinePosition(1, 2)))); 83Assert.Equal(-1, Math.Sign(new LinePosition(1, 2).CompareTo(new LinePosition(2, 1)))); 88Assert.Equal(+1, Math.Sign(new LinePosition(1, 2).CompareTo(new LinePosition(1, 1)))); 91Assert.Equal(+1, Math.Sign(new LinePosition(2, 1).CompareTo(new LinePosition(1, 2))));
RealParserTests.cs (2)
448f = (float)Math.Pow(2.0, i); 467f = (float)Math.Pow(10.0, i);
Text\CompositeTextTests.cs (1)
58for (var sourceTextCount = minSourceTextCount; sourceTextCount <= Math.Min(maxSourceTextCount, contents.Length); sourceTextCount++)
Microsoft.CodeAnalysis.VisualBasic (2)
Syntax\SyntaxReplacer.vb (2)
123start = Math.Min(start, span.Start) 124[end] = Math.Max([end], span.End)
Microsoft.CodeAnalysis.Workspaces (109)
Classification\SyntaxClassification\SyntacticChangeRangeComputer.cs (2)
110commonRightWidth = Math.Min(commonRightWidth, oldRootWidth - commonLeftWidth.Value); 111commonRightWidth = Math.Min(commonRightWidth, newRootWidth - commonLeftWidth.Value);
Differencing\LongestCommonSubsequence.cs (2)
122=> 2 * Math.Max(depth, 1) + 1; 396var max = Math.Max(oldLength, newLength);
FindSymbols\FindReferences\DependentProjectsFinder.cs (1)
127projectAndVisibility.visibility = (SymbolVisibility)Math.Min((int)projectAndVisibility.visibility, (int)symbol.GetResultantVisibility());
FindSymbols\FindReferences\FindReferenceCache.cs (1)
206nextIndex = Math.Max(nextIndex, token.SpanStart);
FindSymbols\TopLevelSyntaxTree\DeclaredSymbolInfo.cs (2)
130parameterCount = Math.Min(parameterCount, (byte)Max4BitValue); 131typeParameterCount = Math.Min(typeParameterCount, (byte)Max4BitValue);
PatternMatching\AllLowerCamelCaseMatcher.cs (1)
158var maxHumpMatchLength = Math.Min(maxPatternHumpLength, maxCandidateHumpLength);
Shared\Extensions\FileLinePositionSpanExtensions.cs (4)
48var startColumn = Math.Max(span.Start.Character, 0); 49var endColumn = Math.Max(span.End.Character, 0); 78startColumn = Math.Min(startColumn, lines[startLine].SpanIncludingLineBreak.Length); 79endColumn = Math.Min(endColumn, lines[endLine].SpanIncludingLineBreak.Length);
Shared\Extensions\INamespaceSymbolExtensions.cs (1)
45for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++)
Shared\Extensions\SourceTextExtensions.cs (3)
214var count = Math.Min(buffer.Length, length - offset); 343var totalCharsToRead = Math.Min(count, Length - Position); 352var charsToCopy = Math.Min(chunk.Length - chunkStartOffset, count);
Shared\Utilities\BloomFilter.cs (10)
41var m = Math.Max(1, ComputeM(expectedCount, falsePositiveProbability)); 42var k = Math.Max(1, ComputeK(expectedCount, falsePositiveProbability)); 82var numerator = n * Math.Log(p); 83var denominator = Math.Log(1.0 / Math.Pow(2.0, Math.Log(2.0))); 84return unchecked((int)Math.Ceiling(numerator / denominator)); 93var temp = Math.Log(2.0) * m / n; 94return unchecked((int)Math.Round(temp)); 331return Math.Abs(hash);
Shared\Utilities\DocumentationComment.cs (1)
207maxPrefix = Math.Min(maxPrefix, firstNonWhitespaceOffset.Value);
Shared\Utilities\XmlFragmentParser.cs (1)
199var charCount = Math.Min(src.Length - srcIndex, destCount);
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (2)
566var maxSearchIndex = Math.Min(directoryPathParts.Length, fullPathParts.Length); 648return PathsEqual(path1, path2, Math.Max(path1.Length, path2.Length));
src\Compilers\Core\Portable\Hashing\XxHashShared.cs (1)
465return Math.BigMul(left, right, out lower);
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
src\Compilers\Core\Portable\Syntax\SyntaxTreeExtensions.cs (1)
92var n = Math.Min(n1, n2);
src\Compilers\Core\Portable\Text\TextChangeRangeExtensions.cs (1)
224var oldChangeLeadingDeletion = Math.Min(oldChange.Span.Length, oldChangeLeadingInsertion);
src\Dependencies\Collections\Internal\HashHelpers.cs (1)
49var limit = (int)Math.Sqrt(candidate);
src\Dependencies\Collections\SegmentedArray.cs (10)
494var currentSegmentLength = Math.Min(remainingInSegment, _length); 503var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed); 598var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 646var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 736_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 743_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed)); 785_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 792_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\Dependencies\Collections\SegmentedList`1.cs (1)
544var newSegmentCount = oldSegmentCount + Math.Max(1, oldSegmentCount >> segmentGrowthShiftValue);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\ImmutableIntervalTree`1.cs (1)
198var elementsInLastRowCappedAtMidwayPoint = Math.Min(elementsInLastIncompleteRow, elementsInLastRowIfTreeWerePerfect / 2);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\IntervalTreeAlgorithms`2.cs (2)
146var overlapStart = Math.Max(thisStart, otherStart); 147var overlapEnd = Math.Min(thisEnd, otherEnd);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\MutableIntervalTree`1.Node.cs (1)
35this.Height = 1 + Math.Max(Height(left), Height(right));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Collections\NormalizedTextSpanCollection.cs (5)
296spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span1.End)); 307spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span2.Start)); 334spans.Add(TextSpan.FromBounds(Math.Max(lastEnd, span1.Start), span1.End)); 581end = Math.Max(end, span.End); 617oldEnd = Math.Max(oldEnd, newEnd);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\Common\EmbeddedSyntaxNode.cs (2)
118start = Math.Min(token.VirtualChars[0].Span.Start, start); 119end = Math.Max(token.VirtualChars.Last().Span.End, end);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\EmbeddedLanguages\Common\EmbeddedSyntaxToken.cs (4)
82Math.Min(LeadingTrivia.Length == 0 ? int.MaxValue : LeadingTrivia[0].GetSpan().Start, 83Math.Min(VirtualChars.Length == 0 ? int.MaxValue : VirtualChars[0].Span.Start, 87Math.Max(LeadingTrivia.Length == 0 ? int.MinValue : LeadingTrivia[^1].GetSpan().End, 88Math.Max(VirtualChars.Length == 0 ? int.MinValue : VirtualChars[^1].Span.End,
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\INamespaceOrTypeSymbolExtensions.cs (1)
44for (var i = 0; i < Math.Min(names1.Count, names2.Count); i++)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\ISymbolExtensions.cs (3)
127if (bestMethod is null || Math.Abs(method.Parameters.Length - parameterCount) < Math.Abs(bestMethod.Parameters.Length - parameterCount)) 500var count = extensionUsedAsInstance ? Math.Max(0, method.Parameters.Length - 1) : method.Parameters.Length;
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\SyntaxNodeExtensions.cs (2)
305Math.Min(fullSpan.Start, node.SpanStart), 306Math.Max(fullSpan.End, node.Span.End));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Extensions\TextSpanExtensions.cs (2)
79var startSegmentEnd = Math.Min(span.End, except.Start); 83var endSegmentStart = Math.Max(span.Start, except.End);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\BottomUpBaseIndentationFinder.cs (2)
173return Math.Max(0, baseIndentation + (indentationLevel + delta) * _indentationSize); 178return Math.Max(0, indentationLevel + extraSpaces);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Engine\AbstractTriviaDataFactory.FormattedWhitespace.cs (2)
23this.LineBreaks = Math.Max(0, lineBreaks); 24this.Spaces = Math.Max(0, indentation);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\FormattingExtensions.cs (3)
91var numberOfSpaces = Math.Max(0, desiredIndentation); 105var numberOfSpaces = Math.Max(0, desiredIndentation); 222return Math.Max(currentIndentation + indentationDelta, 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\Rules\BaseIndentationFormattingRule.cs (2)
131=> TextSpan.FromBounds(Math.Max(_span.Start, textSpan.Start), Math.Min(_span.End, textSpan.End));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Formatting\TriviaEngine\AbstractTriviaFormatter.cs (8)
575LineColumnRule.IndentationOperations.Absolute => Math.Max(0, rule.Indentation), 577LineColumnRule.IndentationOperations.Given => (trivia2.RawKind == 0) ? this.Spaces : Math.Max(0, _indentation), 578LineColumnRule.IndentationOperations.Follow => Math.Max(0, lineColumnBeforeTrivia1.Column), 587LineColumnRule.SpaceOperations.Preserve => Math.Max(rule.Spaces, existingWhitespaceBetween.Spaces), 588LineColumnRule.SpaceOperations.Force => Math.Max(rule.Spaces, 0), 595var adjustedRuleLines = Math.Max(0, rule.Lines - GetTrailingLinesAtEndOfTrivia1(lineColumnAfterTrivia1)); 597return (rule.LineOperation == LineColumnRule.LineOperations.Preserve) ? Math.Max(adjustedRuleLines, existingWhitespaceBetween.Lines) : adjustedRuleLines; 746return new TextSpan(Math.Min(this.StartPosition + i + 1, this.EndPosition), 0);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Indentation\AbstractIndentation.Indenter.cs (1)
249=> Math.Min(Root.EndOfFileToken.FullSpan.Start, position);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Log\Logger.LogBlock.cs (1)
17private static readonly ObjectPool<RoslynLogBlock> s_pool = new(() => new RoslynLogBlock(s_pool!), Math.Min(Environment.ProcessorCount * 8, 256));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\NamingStyles\NamingStyle.WordSpanEnumerator.cs (1)
72Current = TextSpan.FromBounds(Current.End, Math.Min(_nameSpan.End, nextWordSeparator));
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Serialization\ObjectWriter.cs (1)
350var segmentLength = Math.Min(buffer.Length, spanLength - offset);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\HeaderFacts\AbstractHeaderFacts.cs (1)
97return Math.Min(afterAttributesToken.Span.Start, node.Span.End);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Services\SyntaxFacts\ISyntaxFactsExtensions.cs (1)
459var startOfNodeWithoutAttributes = Math.Min(afterAttributesToken.Span.Start, endOfNode);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\BKTree.Builder.cs (3)
132var edges = ImmutableArray.CreateBuilder<Edge>(Math.Max(0, _builderNodes.Length - 1)); 153var end = start + Math.Min(edgeCount, CompactEdgeAllocationSize); 263var end = start + Math.Min(currentNode.EdgeCount, CompactEdgeAllocationSize);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\EditDistance.cs (3)
482threshold = Math.Min(threshold, targetLength); 498var jStart = Math.Max(1, i - offset); 499var jEnd = Math.Min(targetLength, i + minimumEditCount + offset);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SerializableBytes.cs (5)
45var count = (int)Math.Min(ChunkSize, length - i); 196var copyCount = Math.Min(Math.Min(ChunkSize - currentOffset, count), (int)(length - position)); 232var copyCount = Math.Min(chunk.Length, count); 383var writeCount = Math.Min(ChunkSize - currentOffset, countLeft);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\StringEscapeEncoder.cs (1)
21var index = prefixIndex >= 0 && prohibitIndex >= 0 ? Math.Min(prefixIndex, prohibitIndex)
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\WordSimilarityChecker.cs (2)
113if (Math.Abs(_source.Length - candidateText.Length) <= _threshold) 142var lengthDifference = Math.Abs(originalText.Length - candidateText.Length);
TemporaryStorage\TemporaryStorageService.DirectMemoryAccessStreamReader.cs (1)
66count = Math.Min(count, (int)(_end - _position));
Workspace\Solution\Checksum_Factory.cs (1)
109var count = Math.Min(maxStackAllocCount, checksumsCount - checksumsIndex);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (24)
src\Compilers\Core\Portable\CaseInsensitiveComparison.cs (2)
111int len = Math.Min(str1.Length, str2.Length); 127int len = Math.Min(str1.Length, str2.Length);
src\Compilers\Core\Portable\FileSystem\PathUtilities.cs (2)
566var maxSearchIndex = Math.Min(directoryPathParts.Length, fullPathParts.Length); 648return PathsEqual(path1, path2, Math.Max(path1.Length, path2.Length));
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
src\Compilers\Core\Portable\InternalUtilities\ReadOnlyUnmanagedMemoryStream.cs (1)
37int bytesRead = Math.Min(count, _length - _position);
src\Compilers\Core\Portable\InternalUtilities\WeakList.cs (1)
91return Math.Max((baseSize * 2) + 1, MinimalNonEmptySize);
src\Dependencies\Collections\Internal\HashHelpers.cs (1)
49var limit = (int)Math.Sqrt(candidate);
src\Dependencies\Collections\SegmentedArray.cs (10)
494var currentSegmentLength = Math.Min(remainingInSegment, _length); 503var currentSegmentLength = Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed); 598var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 646var currentSegmentLength = Math.Min(Math.Min(remainingInFirstSegment, remainingInSecondSegment), _length - _completed); 736_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 743_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed)); 785_current = segment.AsMemory().Slice(offset, Math.Min(remainingInSegment, _length)); 792_current = segment.AsMemory().Slice(0, Math.Min(SegmentedArrayHelper.GetSegmentSize<T>(), _length - _completed));
src\Dependencies\Collections\SegmentedList`1.cs (1)
544var newSegmentCount = oldSegmentCount + Math.Max(1, oldSegmentCount >> segmentGrowthShiftValue);
src\Workspaces\SharedUtilitiesAndExtensions\Compiler\Core\Utilities\SerializableBytes.cs (5)
45var count = (int)Math.Min(ChunkSize, length - i); 196var copyCount = Math.Min(Math.Min(ChunkSize - currentOffset, count), (int)(length - position)); 232var copyCount = Math.Min(chunk.Length, count); 383var writeCount = Math.Min(ChunkSize - currentOffset, countLeft);
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
Differencing\TestTreeComparer.cs (1)
30=> Math.Abs((double)left.Value - right.Value) / TestNode.MaxValue;
Microsoft.Data.Analysis (140)
DataFrame.Arrow.cs (2)
189int numberOfRowsInThisRecordBatch = (int)Math.Min(recordBatchLength, Rows.Count); 198numberOfRowsInThisRecordBatch = (int)Math.Min(numberOfRowsInThisRecordBatch, column.GetMaxRecordBatchLength(numberOfRowsProcessed));
DataFrame.cs (4)
343int shuffleUpperLimit = (int)Math.Min(Int32.MaxValue, Rows.Count); 711longestColumnName = Math.Max(longestColumnName, Columns[i].Name.Length); 714int padding = Math.Max(10, longestColumnName + 1); 721long numberOfRows = Math.Min(Rows.Count, rowsToShow);
DataFrame.IO.cs (1)
425numberOfColumns = Math.Max(numberOfColumns, fields.Length);
DataFrame.Join.cs (4)
57long minLength = Math.Min(Rows.Count, other.Rows.Count); 80long minLength = Math.Min(Rows.Count, other.Rows.Count); 108long newRowCount = Math.Max(Rows.Count, other.Rows.Count); 125long newRowCount = Math.Min(Rows.Count, other.Rows.Count);
DataFrameBuffer.cs (3)
48_memory = new byte[Math.Max(capacity, MinCapacity) * Size]; 83var doubledSize = (int)Math.Min((long)ReadOnlyBuffer.Length * 2, ArrayUtility.ArrayMaxSize); 84var newCapacity = Math.Max(newLength * Size, doubledSize);
DataFrameColumn.cs (1)
440var numberOfRows = Math.Min(Length, rowsToShow);
DataFrameColumns\StringDataFrameColumn.cs (1)
31List<string> buffer = new List<string>((int)Math.Min(MaxCapacity, bufferLen));
DataFrameColumns\VBufferDataFrameColumn.cs (1)
34int bufferLen = (int)Math.Min(MaxCapacity, length - _vBuffers.Count * MaxCapacity);
PrimitiveColumnContainer.cs (2)
160int allocatable = (int)Math.Min(remaining, ReadOnlyDataFrameBuffer<T>.MaxCapacity - originalBufferLength); 373long endIndex = Math.Min(Length, startIndex + length);
PrimitiveDataFrameColumn.cs (1)
215long endIndex = Math.Min(Length, startIndex + length);
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.Data.Analysis.Interactive (1)
DataFrameKernelExtension.cs (1)
56var rowCount = Math.Min(maxRowCount, df.Rows.Count);
Microsoft.DotNet.Build.Tasks.Feed (2)
src\common\GeneralUtils.cs (1)
71int minBytesAvailable = Math.Min(bytesLocalAvailable, bytesRemoteAvailable);
src\CreateAzureDevOpsFeed.cs (1)
214return project.Substring(0, Math.Min(3, project.Length));
Microsoft.DotNet.Build.Tasks.Feed.Tests (2)
PublishArtifactsInManifestTests.cs (2)
211int bytesToWrite = Math.Min(Math.Min(_streamBytes.Length - _position, count), maxStreamBytesThisCall);
Microsoft.DotNet.Build.Tasks.Installers (1)
src\ExecWithRetries.cs (1)
99Math.Pow(RetryDelayBase, i) + RetryDelayConstant);
Microsoft.DotNet.Helix.Sdk (2)
AzureDevOpsTask.cs (2)
177var min = (int)(Math.Pow(factor, attempt) * 1000); 178var max = (int)(Math.Pow(factor, attempt + 1) * 1000);
Microsoft.DotNet.NuGetRepack.Tests (3)
TestHelpers\DiffUtil.cs (3)
211int max = Math.Max(lengthA, lengthB); 263d[i, j] = Math.Min(Math.Min(m1, m2), m3);
Microsoft.DotNet.RemoteExecutor (1)
RemoteExecutor.cs (1)
105return 60 * 1000 * Math.Max(failWaitTimeoutMultiplier, 1);
Microsoft.DotNet.SignTool (2)
src\Hash.cs (1)
76var maxSize = Math.Min(maxItemsToHash, values.Length);
src\SignToolTask.cs (1)
352int min = Math.Min(dir1.Length, dir2.Length);
Microsoft.DotNet.VersionTools (1)
Dependencies\Submodule\SubmoduleDependencyInfo.cs (1)
97public string SimpleVersion => Commit?.Substring(0, Math.Min(7, Commit.Length)) ?? "latest";
Microsoft.DotNet.XliffTasks (1)
StringExtensions.cs (1)
49replacementCount = Math.Max(replacementCount, index + 1);
Microsoft.DotNet.XUnitAssert.Tests (15)
AsyncCollectionAssertsTests.cs (12)
754 var padding = Math.Max(expectedType.Length, actualType.Length); 792 var padding = Math.Max(expectedType.Length, actualType.Length); 873 var padding = Math.Max(expectedType.Length, actualType.Length); 925 var padding = Math.Max(expectedType.Length, actualType.Length); 965 var padding = Math.Max(expectedType.Length, actualType.Length); 1026 var padding = Math.Max(expectedType.Length, actualType.Length); 1141 var padding = Math.Max(expectedType.Length, actualType.Length); 1191 var padding = Math.Max(expectedType.Length, actualType.Length); 1232 var padding = Math.Max(expectedType.Length, actualType.Length); 1274 var padding = Math.Max(expectedType.Length, actualType.Length); 1332 var padding = Math.Max(expectedType.Length, actualType.Length); 1359 var padding = Math.Max(expectedType.Length, actualType.Length);
Sdk\ArgumentFormatterTests.cs (3)
134 var floatPI = (float)Math.PI; 146 Assert.Equal(Math.PI.ToString("G17"), ArgumentFormatter.Format(Math.PI));
Microsoft.Extensions.Caching.Hybrid (2)
Internal\RecyclableArrayBufferWriter.cs (2)
165var growBy = Math.Max(sizeHint, currentLength); 169growBy = Math.Max(growBy, DefaultInitialBufferSize);
Microsoft.Extensions.Caching.StackExchangeRedis (1)
RedisCache.cs (1)
573return (long)Math.Min(
Microsoft.Extensions.DependencyInjection (3)
DependencyInjectionEventSource.cs (2)
118format.Substring(i * MaxChunkSize, Math.Min(MaxChunkSize, format.Length - i * MaxChunkSize)), i, chunkCount, 233descriptorString.Substring(i * MaxChunkSize, Math.Min(MaxChunkSize, descriptorString.Length - i * MaxChunkSize)), i, chunkCount);
ServiceLookup\CallSiteFactory.cs (1)
367return (CallSiteResultCacheLocation)Math.Max((int)locationA, (int)locationB);
Microsoft.Extensions.DependencyModel (1)
DependencyContextJsonReader.cs (1)
66long expectedLength = Math.Max(utf8Bom.Length, stream.Length - stream.Position) + 1;
Microsoft.Extensions.Diagnostics.ResourceMonitoring (9)
Calculator.cs (1)
41double cpuUtilization = Math.Max(0.0, totalUsageTickDelta / totalSystemTicks * Hundred);
Linux\LinuxUtilizationProvider.cs (2)
107double percentage = Math.Min(One, (double)deltaCgroup / deltaHost); 140double memoryPercentage = Math.Min(One, (double)memoryUsed / _memoryLimit);
ResourceUtilization.cs (2)
65CpuUsedPercentage = Math.Min(Hundred, Throw.IfLessThan(cpuUsedPercentage / guaranteedCpuUnits, 0.0)); 68MemoryUsedPercentage = Math.Min(Hundred, (double)MemoryUsedInBytes / systemResources.GuaranteedMemoryInBytes * Hundred);
Windows\WindowsContainerSnapshotProvider.cs (2)
198_memoryPercentage = Math.Min(Hundred, memoryUsage / _memoryLimit * Hundred); // Don't change calculation order, otherwise we loose some precision 232_cpuPercentage = Math.Min(Hundred, usageTickDelta / timeTickDelta * Hundred); // Don't change calculation order, otherwise precision is lost.
Windows\WindowsSnapshotProvider.cs (2)
139_memoryPercentage = Math.Min(Hundred, currentMemoryUsage / _totalMemory * Hundred); // Don't change calculation order, otherwise we loose some precision 171_cpuPercentage = Math.Min(Hundred, usageTickDelta / (double)timeTickDelta * Hundred); // Don't change calculation order, otherwise we loose some precision
Microsoft.Extensions.Diagnostics.ResourceMonitoring.Tests (10)
CircularBufferTests.cs (1)
34var expectedBufferElements = elementsToAdd.Skip(Math.Max(0, elementsToAdd.Count - BufferSize)).ToList();
Linux\AcceptanceTest.cs (5)
180Assert.Equal(0.1, Math.Round(provider.Resources.GuaranteedCpuUnits, 1)); // hack to make hardcoded calculation in resource utilization main package work. 181Assert.Equal(0.2d, Math.Round(provider.Resources.MaximumCpuUnits, 1)); // read from cpuset.cpus 349var roundedCpuUsedPercentage = Math.Round(utilization.CpuUsedPercentage, 1); 354Assert.Equal(roundedCpuUsedPercentage, Math.Round(cpuRequestFromGauge * 100)); 356Assert.Equal(roundedCpuUsedPercentage, Math.Round(cpuFromGauge * 100));
Linux\LinuxUtilizationParserCgroupV2Tests.cs (1)
464var r = Math.Round(p.GetCgroupRequestCpu());
Linux\Resources\FileNamesOnlyFileSystem.cs (1)
49var min = Math.Min(length, c.Length);
Linux\Resources\HardcodedValueFileSystem.cs (1)
80var min = Math.Min(toRead.Length, length);
ResourceUtilizationTests.cs (1)
23Assert.Equal(Math.Min(1.0, (double)MemoryUsed / MemoryTotal) * 100.0, utilization.MemoryUsedPercentage);
Microsoft.Extensions.FileProviders.Physical (1)
PollingWildCardChangeToken.cs (1)
174_byteBuffer = new byte[Math.Max(byteCount, 256)];
Microsoft.Extensions.Http.Diagnostics (1)
Logging\Internal\HttpRequestBodyReader.cs (1)
95var readLimit = Math.Min(readSizeLimit, (int)streamToReadFrom.Length);
Microsoft.Extensions.Identity.Core (2)
AuthenticatorTokenProvider.cs (1)
63var unixTimestamp = Convert.ToInt64(Math.Round((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds));
Base32.cs (1)
96var bits = Math.Min(5 - bitIndex, 8 - outputBits);
Microsoft.Extensions.Logging.Abstractions (2)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
Microsoft.Extensions.Logging.Console (2)
src\libraries\Common\src\System\Text\Json\PooledByteBufferWriter.cs (2)
182sizeHint = Math.Max(sizeHint, MaximumBufferSize - currentLength); 187int growBy = Math.Max(sizeHint, currentLength);
Microsoft.Extensions.Logging.Generators (1)
LoggerMessageGenerator.Parser.cs (1)
919return Math.Abs((int)result);
Microsoft.Extensions.Options.SourceGeneration (1)
OptionsSourceGenContext.cs (1)
80return Math.Abs((int)result);
Microsoft.Extensions.Telemetry (4)
Latency\Internal\LatencyConsoleExporter.cs (4)
65nameColumnWidth = Math.Max(nameColumnWidth, latencyData.Checkpoints[i].Name.Length); 81nameColumnWidth = Math.Max(nameColumnWidth, latencyData.Tags[i].Name.Length); 97nameColumnWidth = Math.Max(nameColumnWidth, latencyData.Measures[i].Name.Length); 132nameColumnWidth = Math.Max(nameColumnWidth, nameHeader.Length);
Microsoft.Gen.Logging (1)
Emission\Emitter.Method.cs (1)
154return Math.Abs((int)result);
Microsoft.Interop.SourceGeneration (4)
SyntaxExtensions.cs (1)
114(_, _) => Math.Min(idxPartial, idxRef)
TypeSymbolExtensions.cs (1)
278int numArgumentsToCopy = Math.Min(numArgumentsToInsert, typeArgumentsToSubstitute.Length - currentArityOffset);
UseSiteAttributeProvider.cs (2)
51_maxIndirectionLevelDataProvided = Math.Max(_maxIndirectionLevelDataProvided, indirectionDepth); 81_maxIndirectionLevelUsed = Math.Max(indirectionDepth, _maxIndirectionLevelUsed);
Microsoft.JSInterop (2)
src\Components\Shared\src\ArrayBuilder.cs (2)
90var candidateCapacity = Math.Max(_items.Length * 2, _minCapacity); 179var newCapacity = Math.Max(desiredCapacity, _minCapacity);
Microsoft.Maui (60)
Animations\Animation.cs (1)
217 var percent = Math.Min(start / Duration, 1);
Animations\Easing.cs (9)
31 public static readonly Easing SinOut = new(x => Math.Sin(x * Math.PI * 0.5f)); 36 public static readonly Easing SinIn = new(x => 1.0f - Math.Cos(x * Math.PI * 0.5f)); 41 public static readonly Easing SinInOut = new(x => -Math.Cos(Math.PI * x) / 2.0f + 0.5f); 51 public static readonly Easing CubicOut = new(x => Math.Pow(x - 1.0f, 3.0f) + 1.0f); 56 public static readonly Easing CubicInOut = new(x => x < 0.5f ? Math.Pow(x * 2.0f, 3.0f) / 2.0f : (Math.Pow((x - 1) * 2.0f, 3.0f) + 2.0f) / 2.0f);
Extensions\IndicatorViewExtensions.cs (1)
15 var minValue = Math.Min(indicatorView.MaximumVisible, indicatorView.Count);
Layouts\AbsoluteLayoutManager.cs (2)
49 measuredHeight = Math.Max(measuredHeight, bounds.Top + height); 50 measuredWidth = Math.Max(measuredWidth, bounds.Left + width);
Layouts\Flex.cs (2)
962 width = Math.Max(0, width - item.PaddingLeft + item.PaddingRight); 963 height = Math.Max(0, height - item.PaddingTop + item.PaddingBottom);
Layouts\FlexLayoutManager.cs (2)
63 measuredHeight = Math.Max(measuredHeight, frame.Bottom); 64 measuredWidth = Math.Max(measuredWidth, frame.Right);
Layouts\GridLayoutManager.cs (7)
638 starSize = Math.Max(starSize, dimension(_childrenToLayOut[cell.ViewIndex].DesiredSize)); 726 var cellRequiredHeight = Math.Min(_gridHeightConstraint, _childrenToLayOut[cell.ViewIndex].DesiredSize.Height); 750 var cellRequiredWidth = Math.Min(_gridWidthConstraint, _childrenToLayOut[cell.ViewIndex].DesiredSize.Width); 872 def.Size = Math.Min(maxSize, def.Size); 873 def.MinimumSize = Math.Min(maxSize, def.MinimumSize); 912 maxCurrentSize = Math.Max(maxCurrentSize, definitionSize); 913 maxCurrentStarSize = Math.Max(maxCurrentStarSize, definitionSize / definition.GridLength.Value);
Layouts\HorizontalStackLayoutManager.cs (1)
32 measuredHeight = Math.Max(measuredHeight, measure.Height);
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);
Layouts\LayoutManager.cs (1)
33 return Math.Min(length, externalConstraint);
Layouts\VerticalStackLayoutManager.cs (1)
33 measuredWidth = Math.Max(measuredWidth, measure.Width);
Platform\ViewExtensions.cs (2)
38 internal static double ExtractAngleInRadians(this Matrix4x4 matrix) => Math.Atan2(matrix.M21, matrix.M11); 40 internal static double ExtractAngleInDegrees(this Matrix4x4 matrix) => ExtractAngleInRadians(matrix) * 180 / Math.PI;
Primitives\GridLength.cs (1)
69 return GridUnitType == other.GridUnitType && Math.Abs(Value - other.Value) < double.Epsilon;
Primitives\SwipeDirection.cs (3)
31 double rad = Math.Atan2(y1 - y2, x2 - x1) + Math.PI; 32 return (rad * 180 / Math.PI + 180) % 360;
VisualDiagnostics\AdornerModel.cs (17)
49 rc.Left = Math.Min(rect.Left - margin.Left, rect.Left); 50 rc.Width = Math.Abs(margin.Left); 60 rc.Left = Math.Min(rect.Right, rect.Right + margin.Right); 61 rc.Width = Math.Abs(margin.Right); 71 rc.Left = rect.Left - Math.Max(0, margin.Left); 72 rc.Right = rect.Right + Math.Max(0, margin.Right); 73 rc.Top = Math.Min(rect.Top - margin.Top, rect.Top); 74 rc.Height = Math.Abs(margin.Top); 82 rc.Left = rect.Left - Math.Max(0, margin.Left); 83 rc.Right = rect.Right + Math.Max(0, margin.Right); 84 rc.Top = Math.Min(rect.Bottom + margin.Bottom, rect.Bottom); 85 rc.Height = Math.Abs(margin.Bottom); 111 double floorPixels = (double)Math.Floor(pixels); 113 floorPixels : (double)Math.Ceiling(pixels); 161 return Math.Abs(value) < Tolerances.ZeroThreshold; 170 double eps = (Math.Abs(value1) + Math.Abs(value2) + 10.0) * Tolerances.Epsilon;
Microsoft.Maui.Controls (165)
Animation.cs (2)
90 double val = Math.Max(0.0f, Math.Min(1.0f, (f - animation.StartDelay) / (animation.Duration)));
AnimationExtensions.cs (3)
292 double sign = velocity / Math.Abs(velocity); 293 velocity = Math.Abs(velocity); 300 velocity = Math.Max(0, velocity);
Brush\BrushTypeConverter.cs (1)
398 result = Math.Min(value / 100, 1f);
DisplayInfoExtensions.cs (1)
19 Math.Round(value);
GradientStop.cs (1)
47 return Color == dest.Color && global::System.Math.Abs(Offset - dest.Offset) < 0.00001;
ImageElement.cs (5)
66 height = Math.Min(desiredHeight, heightConstraint); 70 width = Math.Min(desiredWidth, widthConstraint); 82 width = Math.Min(desiredWidth, widthConstraint); 86 height = Math.Min(desiredHeight, heightConstraint); 94 width = Math.Min(desiredWidth, widthConstraint);
Internals\ImageParser.cs (2)
419 Delay = Math.Max(10, delay * 10); 429 return (short)(Math.Pow(2, (flags & 0x07) + 1));
Internals\ProfilePage.cs (1)
83 var percentage = (int)Math.Round(ticksMs / (double)profiledMs * 100);
Items\ItemsView.cs (2)
199 var maxWidth = Math.Min(scaled.Width, widthConstraint); 200 var maxHeight = Math.Min(scaled.Height, heightConstraint);
LegacyLayouts\AbsoluteLayout.cs (8)
103 bestFitSize.Width = Math.Max(bestFitSize.Width, desiredSize.Request.Width); 104 bestFitSize.Height = Math.Max(bestFitSize.Height, desiredSize.Request.Height); 105 minimum.Width = Math.Max(minimum.Width, desiredSize.Minimum.Width); 106 minimum.Height = Math.Max(minimum.Height, desiredSize.Minimum.Height); 204 width += sizeRequest.Value.Request.Width / Math.Max(0.25, bounds.Width); 223 height += sizeRequest.Value.Request.Height / Math.Max(0.25, bounds.Height); 285 result.X = Math.Round((region.Width - result.Width) * bounds.X); 294 result.Y = Math.Round((region.Height - result.Height) * bounds.Y);
LegacyLayouts\FlexLayout.cs (2)
464 widthConstraint = Math.Max(widthConstraint, item.Frame[0] + item.Frame[2] + item.MarginRight); 470 heightConstraint = Math.Max(heightConstraint, item.Frame[1] + item.Frame[3] + item.MarginBottom);
LegacyLayouts\Grid.cs (2)
388 private int RowCount() => Math.Max( 393 private int ColumnCount() => Math.Max(
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);
LegacyLayouts\Layout.cs (6)
249 double diff = Math.Max(0, region.Width - request.Request.Width); 266 double diff = Math.Max(0, region.Height - request.Request.Height); 460 double w = Math.Max(0, width - Padding.HorizontalThickness); 461 double h = Math.Max(0, height - Padding.VerticalThickness); 513 double diff = Math.Max(0, region.Width - request.Request.Width); 530 double diff = Math.Max(0, region.Height - request.Request.Height);
LegacyLayouts\RelativeLayout.cs (4)
225 boundsRectangle.Left = Math.Min(boundsRectangle.Left, bounds.Left); 226 boundsRectangle.Top = Math.Min(boundsRectangle.Top, bounds.Top); 227 boundsRectangle.Right = Math.Max(boundsRectangle.Right, bounds.Right); 228 boundsRectangle.Bottom = Math.Max(boundsRectangle.Bottom, bounds.Bottom);
LegacyLayouts\StackLayout.cs (8)
178 layout.CompressionSpace += Math.Max(0, request.Request.Height - request.Minimum.Height); 181 boundsWidth = Math.Max(boundsWidth, request.Request.Width); 184 minimumWidth = Math.Max(minimumWidth, request.Minimum.Width); 213 layout.CompressionSpace += Math.Max(0, request.Request.Width - request.Minimum.Width); 217 boundsHeight = Math.Max(boundsHeight, request.Request.Height); 219 minimumHeight = Math.Max(minimumHeight, request.Minimum.Height); 281 layout.Bounds.Height = Math.Max(layout.Bounds.Height, plot.Height); 353 layout.Bounds.Width = Math.Max(layout.Bounds.Width, plot.Width);
ListView\ListView.cs (2)
428 double width = Math.Min(scaled.Width, scaled.Height); 439 request = new Size(width, Math.Max(scaled.Width, scaled.Height));
MultiBinding.cs (1)
121 for (var i = 0; i < Math.Min(_bpProxies.Length, values.Length); i++)
NumericExtensions.cs (1)
13 if (Math.Abs(sizeA - sizeB) > Tolerance)
Page\Page.cs (4)
426 area.Width = Math.Max(0, area.Width); 427 area.Height = Math.Max(0, area.Height); 589 double w = Math.Max(0, Width - Padding.HorizontalThickness); 590 double h = Math.Max(0, Height - Padding.VerticalThickness);
ScrollView\ScrollView.cs (2)
317 contentRequest.Minimum = new Size(Math.Min(40, contentRequest.Minimum.Width), Math.Min(40, contentRequest.Minimum.Height));
Shapes\GeometryHelper.cs (20)
76 double x = elipGeoSrc.Center.X + elipGeoSrc.RadiusX * Math.Sin(i * 2 * Math.PI / max); 77 double y = elipGeoSrc.Center.Y - elipGeoSrc.RadiusY * Math.Cos(i * 2 * Math.PI / max); 290 double vectLength = Math.Sqrt(vect.X * vect.X + vect.Y * vect.Y); 301 double vectRotatedLength = Math.Sqrt(vectRotated.X * vectRotated.X + vectRotated.Y * vectRotated.Y); 308 double centerDistance = Math.Sqrt(Math.Abs((radiusY * radiusY) - (halfChord * halfChord))); 316 double angle1 = Math.Atan2(pt1.Y - center.Y, pt1.X - center.X); 317 double angle2 = Math.Atan2(pt2.Y - center.Y, pt2.X - center.X); 319 double sweep = Math.Abs(angle2 - angle1); 322 if (Math.IEEERemainder(sweep + 0.000005, Math.PI) < 0.000010) 328 bool isAcute = sweep < Math.PI; 335 angle1 += 2 * Math.PI; 337 angle2 += 2 * Math.PI; 344 int max = (int)(4 * (radiusX + radiusY) * Math.Abs(angle2 - angle1) / (2 * Math.PI) / tolerance); 349 double x = center.X + radiusY * Math.Cos(angle); 350 double y = center.Y + radiusY * Math.Sin(angle);
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;
Shapes\PathFigureCollectionConverter.cs (2)
498 currentIndex = Math.Min(currentIndex + 8, pathLength); // "Infinity" has 8 characters 508 currentIndex = Math.Min(currentIndex + 3, pathLength); // "NaN" has 3 characters
Shapes\Rectangle.cs (1)
60 float cornerRadius = (float)Math.Max(RadiusX, RadiusY);
Shapes\RotateTransform.cs (3)
72 double radians = Math.PI * Angle / 180; 73 double sin = Math.Sin(radians); 74 double cos = Math.Cos(radians);
Shapes\RoundRectangle.cs (4)
92 float topLeftCornerRadius = (float)Math.Max(0, CornerRadius.TopLeft - strokeThickness); 93 float topRightCornerRadius = (float)Math.Max(0, CornerRadius.TopRight - strokeThickness); 94 float bottomLeftCornerRadius = (float)Math.Max(0, CornerRadius.BottomLeft - strokeThickness); 95 float bottomRightCornerRadius = (float)Math.Max(0, CornerRadius.BottomRight - strokeThickness);
Shapes\Shape.cs (2)
419 double minScale = Math.Min(scaleX, scaleY); 430 double maxScale = Math.Max(scaleX, scaleY);
Shapes\SkewTransform.cs (4)
86 double radiansX = Math.PI * AngleX / 180; 87 double radiansY = Math.PI * AngleY / 180; 88 double tanX = Math.Tan(radiansX); 89 double tanY = Math.Tan(radiansY);
Stepper\Stepper.cs (2)
36 return Math.Round(((double)value), stepper.digits).Clamp(stepper.Minimum, stepper.Maximum); 49 propertyChanged: (b, o, n) => { ((Stepper)b).digits = (int)(-Math.Log10((double)n) + 4).Clamp(1, 15); });
TableView\TableView.cs (2)
139 double width = Math.Min(scaled.Width, scaled.Height); 140 var request = new Size(width, Math.Max(scaled.Width, scaled.Height));
TemplatedItemsList.cs (2)
1000 maxindex = Math.Max(maxindex, e.NewStartingIndex + e.NewItems.Count); 1002 maxindex = Math.Max(maxindex, e.OldStartingIndex + e.OldItems.Count);
Tweener.cs (1)
124 Value = Math.Min(1.0f, ms / (double)Length);
VisualElement\VisualElement.cs (7)
1052 _batched = Math.Max(0, _batched - 1); 1132 widthConstraint = Math.Min(widthConstraint, widthRequest); 1134 heightConstraint = Math.Min(heightConstraint, heightRequest); 1163 minimum.Height = Math.Min(request.Height, minimum.Height); 1164 minimum.Width = Math.Min(request.Width, minimum.Width); 1205 widthConstraint = Math.Max(0, widthConstraint - margin.HorizontalThickness); 1206 heightConstraint = Math.Max(0, heightConstraint - margin.VerticalThickness);
Microsoft.Maui.Controls.BindingSourceGen (1)
BindingSourceGenerator.cs (1)
46 var code = BindingCodeWriter.GenerateBinding(binding, (uint)Math.Abs(binding.Location.GetHashCode()));
Microsoft.Maui.Controls.Compatibility (4)
Tizen\Extensions\BrushExtensions.cs (1)
103 var radius = (float)radialGradientBrush.Radius * Math.Max(pathBounds.Height, pathBounds.Width);
Tizen\Forms.cs (2)
325 return (int)Math.Round(dp * TDeviceInfo.DPI / 160.0); 339 return (int)Math.Round(dp * TDeviceInfo.ScalingFactor);
Tizen\Renderers\VisualElementRenderer.cs (1)
854 return (float)(degree * Math.PI / 180);
Microsoft.Maui.Essentials (11)
Types\Location.shared.cs (1)
67 if (Math.Abs(latitude) > 90)
UnitConverters\UnitConverters.shared.cs (10)
10 const double twoPi = 2.0 * Math.PI; 13 const double degreesToRadians = Math.PI / 180.0; 258 var dLat2 = Math.Sin(dLat / 2) * Math.Sin(dLat / 2); 259 var dLon2 = Math.Sin(dLon / 2) * Math.Sin(dLon / 2); 261 var a = dLat2 + dLon2 * Math.Cos(lat1) * Math.Cos(lat2); 262 var c = 2 * Math.Asin(Math.Sqrt(a));
Microsoft.Maui.Graphics (98)
AbstractCanvas.cs (2)
160 var halfHeight = Math.Abs(height / 2); 164 var halfWidth = Math.Abs(width / 2);
ArcFlattener.cs (4)
31 _diameter = Math.Max(width, height); 36 _sweep = Math.Abs(endAngle - startAngle); 67 var x2 = x + (Math.Cos(radians) * distance); 68 var y2 = y + (Math.Sin(radians) * distance);
Color.cs (11)
153 if (Math.Abs(alpha - Alpha) < GeometryUtil.Epsilon) 196 float v = Math.Max(Red, Green); 197 v = Math.Max(v, Blue); 198 float m = Math.Min(Red, Green); 199 m = Math.Min(m, Blue); 262 var range = (int)(Math.Floor(h * 6)) % 6; 263 var f = h * 6 - Math.Floor(h * 6); 522 float v = Math.Max(r, g); 523 v = Math.Max(v, b); 525 float m = Math.Min(r, g); 526 m = Math.Min(m, b);
GeometryUtil.cs (3)
35 return Math.PI * angle / 180; 45 return angle * (180 / Math.PI); 214 if (Math.Abs(vAdjustedValue - vRange) < Epsilon)
GradientPaint.cs (2)
127 var stopCount = Math.Min(colors.Length, offsets.Length); 196 if (Math.Abs(currentOffset - offset) < GeometryUtil.Epsilon)
Insets.cs (8)
61 return Math.Abs(_top - value) < GeometryUtil.Epsilon && Math.Abs(_left - value) < GeometryUtil.Epsilon && Math.Abs(_right - value) < GeometryUtil.Epsilon && 62 Math.Abs(_bottom - value) < GeometryUtil.Epsilon; 69 return Math.Abs(vCompareTo.Top - Top) < GeometryUtil.Epsilon && Math.Abs(vCompareTo.Left - Left) < GeometryUtil.Epsilon && Math.Abs(vCompareTo.Bottom - Bottom) < GeometryUtil.Epsilon && 70 Math.Abs(vCompareTo.Right - Right) < GeometryUtil.Epsilon;
InsetsF.cs (8)
61 return Math.Abs(_top - value) < GeometryUtil.Epsilon && Math.Abs(_left - value) < GeometryUtil.Epsilon && Math.Abs(_right - value) < GeometryUtil.Epsilon && 62 Math.Abs(_bottom - value) < GeometryUtil.Epsilon; 69 return Math.Abs(vCompareTo.Top - Top) < GeometryUtil.Epsilon && Math.Abs(vCompareTo.Left - Left) < GeometryUtil.Epsilon && Math.Abs(vCompareTo.Bottom - Bottom) < GeometryUtil.Epsilon && 70 Math.Abs(vCompareTo.Right - Right) < GeometryUtil.Epsilon;
Matrix3x2Extensions.cs (5)
53 var sx = matrix.M12 == 0 ? Math.Abs(matrix.M11) : new Vector2(matrix.M11, matrix.M12).Length(); 54 var sy = matrix.M21 == 0 ? Math.Abs(matrix.M22) : new Vector2(matrix.M21, matrix.M22).Length(); 72 var sx = matrix.M12 == 0 ? Math.Abs(matrix.M11) : new Vector2(matrix.M11, matrix.M12).Length(); 73 var sy = matrix.M21 == 0 ? Math.Abs(matrix.M22) : new Vector2(matrix.M21, matrix.M22).Length(); 150 count = Math.Min(dst.Length, count);
PathF.cs (9)
1145 xCornerRadius = Math.Min(xCornerRadius, rect.Width / 2); 1146 yCornerRadius = Math.Min(yCornerRadius, rect.Height / 2); 1148 float minX = Math.Min(rect.X, rect.X + rect.Width); 1149 float minY = Math.Min(rect.Y, rect.Y + rect.Height); 1150 float maxX = Math.Max(rect.X, rect.X + rect.Width); 1151 float maxY = Math.Max(rect.Y, rect.Y + rect.Height); 1316 if (Math.Abs(arcAngle - compareTo.GetArcAngle(i)) > GeometryUtil.Epsilon) 1373 if (Math.Abs(arcAngle - compareTo.GetArcAngle(i)) > epsilon) 1565 numberOfPoints = (int)(Math.Sqrt(rCurve / flatness)) + 3;
Point.cs (7)
62 return Math.Abs(compareTo.X - X) < epsilon && Math.Abs(compareTo.Y - Y) < epsilon; 80 return new Point((double)Math.Round(X), (double)Math.Round(Y)); 117 return (double)Math.Sqrt(Math.Pow(X - other.X, 2) + Math.Pow(Y - other.Y, 2));
PointF.cs (2)
56 return Math.Abs(compareTo.X - X) < epsilon && Math.Abs(compareTo.Y - Y) < epsilon;
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;
ScalingCanvas.cs (2)
215 _scaleX *= Math.Abs(sx); 216 _scaleY *= Math.Abs(sy);
Text\AttributedTextExtensions.cs (5)
114 var paragraphLength = Math.Min(run.Length, length); 132 var paragraphStart = Math.Max(run.Start - start, 0); 133 var paragraphLength = Math.Min(run.Length, end - paragraphStart); 142 var paragraphStart = Math.Max(run.Start - start, 0); 143 var paragraphLength = Math.Min(run.Length, length - paragraphStart);
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)
SkiaCanvas.cs (7)
291 float radius = (float)radialGradientPaint.Radius * Math.Max(rectangle.Height, rectangle.Width); 764 CurrentState.SetScale(Math.Abs(xFactor), Math.Abs(yFactor)); 823 var rx1 = Math.Min(x, x + width); 824 var ry1 = Math.Min(y, y + height); 825 var rx2 = Math.Max(x, x + width); 826 var ry2 = Math.Max(y, y + height);
SkiaTextLayout.cs (2)
103 var maxLines = Math.Floor(height / _lineHeight); 104 linesToDraw = (int)Math.Min(maxLines, lines.Count);
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (10)
src\Graphics\src\Graphics\Platforms\Windows\PlatformCanvas.cs (7)
178 var absRotation = Math.Abs(rotation); 486 float radius = (float)radialGradientPaint.Radius * Math.Max(rectangle.Height, rectangle.Width); 566 var absRotation = Math.Abs(rotation); 853 _rect.X = Math.Min(x, x + width); 854 _rect.Y = Math.Min(y, y + height); 855 _rect.Width = Math.Abs(width); 856 _rect.Height = Math.Abs(height);
src\Graphics\src\Graphics\Platforms\Windows\PlatformCanvasState.cs (1)
445 public float ActualShadowBlur => ShadowBlur * Math.Abs(_scale);
src\Graphics\src\Graphics\Platforms\Windows\PlatformImage.cs (2)
140 canvas.DrawImage(this, dirtyRect.Left, dirtyRect.Top, Math.Abs(dirtyRect.Width), Math.Abs(dirtyRect.Height));
Microsoft.Maui.Maps (40)
Primitives\Distance.cs (7)
63 var distance = Math.Sin((latitude2 - latitude1) / 2.0); 66 var intermediate = Math.Sin((longitude2 - longitude1) / 2.0); 69 distance = distance + Math.Cos(latitude1) * Math.Cos(latitude2) * intermediate; 70 distance = 2 * GeographyUtils.EarthRadiusKm * Math.Atan2(Math.Sqrt(distance), Math.Sqrt(1 - distance));
Primitives\GeographyUtils.cs (15)
12 public static double ToRadians(this double degrees) => degrees * Math.PI / 180.0; 14 public static double ToDegrees(this double radians) => radians / Math.PI * 180.0; 26 double latitude = Math.Asin(Math.Sin(centerLatitude) * Math.Cos(distance) + 27 Math.Cos(centerLatitude) * Math.Sin(distance) * Math.Cos(angleInRadians)); 29 Math.Atan2(Math.Sin(angleInRadians) * Math.Sin(distance) * Math.Cos(centerLatitude), 30 Math.Cos(distance) - Math.Sin(centerLatitude) * Math.Sin(latitude));
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)
SkiaSharpAppIconTools.cs (1)
156 var radius = Math.Min(canvasSize.Width, canvasSize.Height) / 2;
SkiaSharpTools.cs (3)
244 var nominalRatio = Math.Min( 255 (int)Math.Round(scaledWidth), 256 (int)Math.Round(scaledHeight));
Microsoft.ML.AutoML (68)
AutoMLExperiment\IPerformanceMonitor.cs (2)
127_peakCpuUsage = Math.Max(cpuUsageInTotal, _peakCpuUsage ?? 0); 131_peakMemoryUsage = Math.Max(memoryUsage, _peakMemoryUsage ?? 0);
ColumnInference\TextFileSample.cs (5)
126averageLineLength = Math.Max(averageLineLength, 3); 131int chunkCount = (int)Math.Ceiling((BufferSizeMb * OversamplingRate - FirstChunkSizeMb) * (1 << 20) / usefulChunkSize); 132int maxChunkCount = (int)Math.Floor((double)(fileSize - firstChunk.Length) / chunkSize); 133chunkCount = Math.Min(chunkCount, maxChunkCount); 253int sniffLim = Math.Min(1000, buffer.Length);
Experiment\MetricsAgents\RankingMetricsAgent.cs (3)
42return metrics.NormalizedDiscountedCumulativeGains[Math.Min(metrics.NormalizedDiscountedCumulativeGains.Count, (int)_dcgTruncationLevel) - 1]; 44return metrics.DiscountedCumulativeGains[Math.Min(metrics.DiscountedCumulativeGains.Count, (int)_dcgTruncationLevel) - 1]; 73DcgTruncationLevel = Math.Max(10, 2 * (int)_dcgTruncationLevel)
Experiment\Runners\CrossValSummaryRunner.cs (1)
218var distFromAvg = Math.Abs(value - average);
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)));
Sweepers\SmacSweeper.cs (2)
90return _randomSweeper.ProposeSweeps(Math.Min(numOfCandidates, _args.NumberInitialPopulation - numRuns), previousRuns); 157ParameterSet[] eiChallengers = GreedyPlusRandomSearch(bestKParamSets, forest, (int)Math.Ceiling(numOfCandidates / 2.0F), previousRuns);
Sweepers\SweeperProbabilityUtils.cs (9)
16return 1 / Math.Sqrt(2 * Math.PI) * Math.Exp(-Math.Pow(x, 2) / 2); 21return 0.5 * (1 + ProbabilityFunctions.Erf(x * 1 / Math.Sqrt(2))); 41rvs.Add(mu + sigma * Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2));
Tuner\Flow2.cs (3)
50_step = _stepSize * Math.Sqrt(_dim); 51_stepUpperBound = Math.Sqrt(_dim); 112_step = Math.Min(_step, _stepUpperBound);
Tuner\PipelineProposer.cs (3)
154_e2 = _pipelineSchemas.ToDictionary(id => id, id => loss + 0.05 * Math.Abs(loss)); 181var eci1 = Math.Max(_k1[schema], _k2[schema]); 183_eci[schema] = Math.Max(eci1, estimatorCostForBreakThrough);
Tuner\SmacTuner.cs (5)
241if (Math.Abs(eis[maxIndex] - currentBestEI) < _epsilon) 291var newFeatured = mu + sigma * Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2);
Utils\ArrayMath.cs (7)
42return xArray.Select(x => Math.Min(Math.Max(x, min), max)).ToArray(); 76return Math.Sqrt(s); 88return xArray.Select(x => Math.Log(x)).ToArray(); 136var rmse = Math.Sqrt(mean); 149var ape = diff.Select((x, i) => Math.Abs(x) / truth[i]); 162var diff = Enumerable.Range(0, truth.Length).Select(i => Math.Abs(truth[i] - pred[i])).ToArray();
Utils\RandomNumberGenerator.cs (4)
37double std = Math.Sqrt(-2.0 * Math.Log(u)) * Math.Sin(2.0 * Math.PI * v);
Utils\StringEditDistance.cs (2)
46rows[nextRow, j] = Math.Min(deletion, Math.Min(insertion, substitution));
Microsoft.ML.AutoML.Tests (13)
SweeperTests.cs (6)
119double metric = -200 * (Math.Abs(100 - x1) + 120Math.Abs(300 - x2) + 121Math.Abs(500 - x3) + 122Math.Abs(700 - x4)); 169double metric = ((5 - Math.Abs(4 - foo)) * 200) + (1001 - Math.Abs(33 - bar)) + rand.Next(1, 20);
TunerTests.cs (7)
269bestMetric = Math.Max(bestMetric, metric); 324bestLoss = Math.Min(bestLoss, loss); 370bestMetric = Math.Min(bestMetric, metric); 433return Math.Log(Math.Exp(x) + Math.Exp(y) + Math.Exp(z));
Microsoft.ML.Core (121)
CommandLine\CmdParser.cs (3)
866maxParamLen = Math.Max(maxParamLen, helpString.Syntax.Length); 875screenWidth = Math.Max(screenWidth, minimumScreenWidth); 915endIndex = helpStrings.Help.LastIndexOf(' ', endIndex - 1, Math.Min(endIndex - index, charsPerLine));
Utilities\BigArray.cs (2)
267Array.Resize(ref _entries[0], Math.Min(BlockSize, Math.Max(2 * curLastBlockSize, newLastBlockLength)));
Utilities\BinFinder.cs (2)
454return Math.Abs(_accum[i] - ideal) < Math.Abs(_accum[j] - ideal);
Utilities\DoubleParser.cs (1)
705Contracts.Assert(Math.Abs(exp) < int.MaxValue);
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;
Utilities\MatrixTransposeOps.cs (8)
40int iend = Math.Min(m - i, _block); 43int jend = Math.Min(n - j, _block); 99int iend = Math.Min(m - i, _block); 100int jend = Math.Min(n - j, _block); 151int iend = Math.Min(m - i, _block); 152int jend = Math.Min(n - j, _block); 204int iend = Math.Min(m - i, _block); 205int jend = Math.Min(n - j, _block);
Utilities\Stats.cs (31)
32int max = (int)Math.Ceiling(Math.Sqrt(rangeSize)); 45private static readonly double _vScale = 2 * Math.Sqrt(2 / Math.E); 63double y = Math.Abs(v) + 0.386595; 65} while (q > 0.27597 && (q > 0.27846 || v * v > -4 * u * u * Math.Log(u))); 82return SampleFromGamma(r, alpha + 1) * Math.Pow(r.NextDouble(), 1.0 / alpha); 85double c = 1 / Math.Sqrt(9 * d); 94v = Math.Pow(1.0 + c * x, 3); 99Math.Log(u) < 0.5 * xSqr + d * (1.0 - v + Math.Log(v))) 147double expLam = Math.Exp(-lambda); 159double sqrtLam = Math.Sqrt(lambda); 193logLam = Math.Log(lambda); 194double p = sqrtLam * Math.Exp(-lambda + k * logLam - logkFac); 224return (float)Math.Tan(Math.PI * (rand.NextSingle() - 0.5)); 271double pin = Math.Min(p, 1 - p); 291double s = Math.Pow(q, n); 315double spq = Math.Sqrt(npq); 340return (int)Math.Floor((a2 / (0.5 - Math.Abs(u)) + b) * u + c); 351u = Math.Sign(u) * 0.5 - u; 356double us = 0.5 - Math.Abs(u); 357double kd = Math.Floor((a2 / us + b) * u + c); 365m = (int)Math.Floor((n + 1) * p); 371int km = Math.Abs(k - m); 400v = Math.Log(v); 415h = (m + 0.5) * Math.Log((m + 1) / (r * nm)) + Fc(m) + Fc(n - m); 417double vval = h + (n + 1) * Math.Log((double)nm / (double)nk) + (k + 0.5) * Math.Log(nk * r / (double)(k + 1)) - Fc(k) - Fc(n - k);
Utilities\Stream.cs (3)
48(read = source.Read(buffer, 0, (int)Math.Min(buffer.Length, remaining))) != 0) 845int desiredWorkSize = (int)Math.Min(blockSize, bytesToRead); 853int toRead = (int)Math.Min(bytesToRead - offset, blockSize);
Utilities\SummaryStatistics.cs (20)
69public double SampleStdDev => Math.Sqrt(SampleVariance); 74public double StandardErrorMean => SampleStdDev / Math.Sqrt(RawCount); 218public double Skewness => Math.Sqrt(Count) * _m3 / Math.Pow(M2, 1.5); 241double y = b1 * Math.Sqrt((n + 1) * (n + 3) / (6 * (n - 2))); 243double w2 = -1.0 + Math.Sqrt(2.0 * (beta - 1.0)); 244double delta = 1.0 / Math.Sqrt(Math.Log(Math.Sqrt(w2))); 245double alpha = Math.Sqrt(2.0 / (w2 - 1.0)); 247double z1 = delta * Math.Log(yDivAlpha + Math.Sqrt(yDivAlpha * yDivAlpha + 1.0)); 274double x = (b2 - e) / Math.Sqrt(var); // Standardized b2. 277Math.Sqrt(n * (n - 2) * (n - 3) / (6 * (n + 3) * (n + 5))); 278double a = 6 + 8 * ibeta * (2 * ibeta + Math.Sqrt(1 + 4 * ibeta * ibeta)); 279double toCubeRoot = (1 - 2 / a) / (1 + x * Math.Sqrt(2 / (a - 4))); 280double z2 = (1 - 2 / (9 * a) - Math.Sign(toCubeRoot) * Math.Pow(Math.Abs(toCubeRoot), 1.0 / 3.0)) / 281Math.Sqrt(2 / (9 * a));
Utilities\SupervisedBinFinder.cs (2)
252Double logN = Math.Log(lim - min); 295entropy -= p * Math.Log(p);
Utilities\TextReaderStream.cs (3)
81_buff = new byte[Math.Max(_encoding.GetByteCount("\n"), _encoding.GetMaxByteCount(_charBlockSize))]; 140int charCount = Math.Min(_line.Length - _lineCur, _charBlockSize); 160int toCopy = Math.Min(count - readCount, _buffLim - _buffCur);
Microsoft.ML.Core.Tests (19)
UnitTests\CoreBaseTestClass.cs (1)
66return FloatUtils.GetBits(x) == FloatUtils.GetBits(y) || Math.Abs(x - y) < DoubleEps;
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));
UnitTests\TestVBuffer.cs (11)
97float l1 = a.Items().Sum(iv => Math.Abs(iv.Value)); 101float infNorm = a.GetValues().Length == 0 ? 0 : a.Items().Max(iv => Math.Abs(iv.Value)); 830var l1Dist = a.Items(all: true).Zip(b.Items(all: true), (av, bv) => Math.Abs(av.Value - bv.Value)).Sum(); 870min = rgen.Next(Math.Min(max + 10, len + 100) - max - 2) + max + 2; 871max = rgen.Next(Math.Min(min + 10, len + 100) - min) + min; 899int expectedLength = Math.Max(1, a.Length - slotsDropped); 935var expectedVector = new VBuffer<float>(Math.Max(1, expectedLength), 1050if (FloatUtils.GetBits(i) == FloatUtils.GetBits(j) || Math.Abs(i - j) == 0) 1053float comp = Math.Abs(i - j) / (Math.Abs(i) + Math.Abs(j));
Microsoft.ML.CpuMath (31)
AvxIntrinsics.cs (2)
1556*pDst2Current = Math.Abs(dst1) > threshold ? (dst1 > 0 ? dst1 - threshold : dst1 + threshold) : 0; 1615pdst2[index] = Math.Abs(dst1) > threshold ? (dst1 > 0 ? dst1 - threshold : dst1 + threshold) : 0;
CpuMathUtils.netcoreapp.cs (5)
307sum += Math.Abs(source[i] - mean); 336float abs = Math.Abs(source[i]); 370float abs = Math.Abs(source[i] - mean); 545w[i] = Math.Abs(value) > threshold ? (value > 0 ? value - threshold : value + threshold) : 0; 588w[index] = Math.Abs(value) > threshold ? (value > 0 ? value - threshold : value + threshold) : 0;
EigenUtils.cs (12)
19var n = (int)Math.Sqrt(count); 38eigenvalues[i] = eigenvalues[i] <= 0 ? (float)(0.0) : (float)Math.Sqrt(eigenvalues[i]); 43x = Math.Abs(x); 44y = Math.Abs(y); 52return y * (float)Math.Sqrt(1 + t * t); 57return x * (float)Math.Sqrt(1 + t * t); 63float xx = Math.Abs(x); 134scale += Math.Abs(d[k]); 158g = CopySign((float)Math.Sqrt(h), (float)f); 358tst1 = Math.Abs(d[m]) + Math.Abs(d[m + 1]); 359tst2 = tst1 + Math.Abs(e[m]);
ProbabilityFunctions.cs (10)
32double t = 1.0 / (1.0 + p * Math.Abs(x)); 33double ev = ((((((((a5 * t) + a4) * t) + a3) * t) + a2) * t + a1) * t) * Math.Exp(-(x * x)); 53double t = 1.0 / (1.0 + p * Math.Abs(x)); 54double ev = 1.0 - ((((((((a5 * t) + a4) * t) + a3) * t) + a2) * t + a1) * t) * Math.Exp(-(x * x)); 83double cc = Math.Sqrt(Math.PI) / 2.0; 84double ccinc = Math.PI / 4.0; 126if (Math.Abs(q) <= 0.425) 140r = Math.Sqrt(-Math.Log(r));
SseIntrinsics.cs (2)
1235*pDst2Current = Math.Abs(dst1) > threshold ? (dst1 > 0 ? dst1 - threshold : dst1 + threshold) : 0; 1280pdst2[index] = Math.Abs(dst1) > threshold ? (dst1 > 0 ? dst1 - threshold : dst1 + threshold) : 0;
Microsoft.ML.CpuMath.PerformanceTests (1)
PerformanceTests.cs (1)
44double exponent = Math.Pow(2.0, rand.Next(-expRange + 1, expRange + 1));
Microsoft.ML.CpuMath.UnitTests (8)
UnitTests.cs (8)
711expected += Math.Abs(src[i]); 737expected += Math.Abs(src[i] - defaultScale); 761float abs = Math.Abs(src[i]); 790float abs = Math.Abs(src[i] - defaultScale); 944expected[i] = Math.Abs(value) > defaultScale ? (value > 0 ? value - defaultScale : value + defaultScale) : 0; 977expected[index] = Math.Abs(value) > defaultScale ? (value > 0 ? value - defaultScale : value + defaultScale) : 0; 1006return Math.Abs(a - b) < 1e-5f; 1019return Math.Abs(a - b) < 1e-3f;
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));
Data\DataViewUtils.cs (2)
100int conc = Math.Max(2, Environment.ProcessorCount - 1); 103return Math.Min(num, 2 * conc);
DataLoadSave\Binary\BinaryLoader.cs (4)
783_threads = Math.Max(1, args.Threads ?? (Environment.ProcessorCount / 2)); 849_threads = Math.Max(1, Environment.ProcessorCount / 2); 857_threads = Math.Max(1, Environment.ProcessorCount / 2); 1171var poolSize = Math.Ceiling(_shuffleBlocks * _rowsPerBlock);
DataLoadSave\Binary\BinarySaver.cs (1)
771return Math.Max(1, rows); // Possible that even a single row exceeds the "limit".
DataLoadSave\Binary\Codecs.cs (2)
212int sublen = Math.Min(byteLength, _buffer.Length); 272int sublen = Math.Min(byteLength, _buffer.Length);
DataLoadSave\Binary\MemoryStreamPool.cs (1)
56return Math.Max(Utils.IbitHigh((uint)maxSize) - 15, 0);
DataLoadSave\Text\TextLoader.cs (1)
746inputSize = Math.Min(min, SrcLim - 1);
DataLoadSave\Text\TextLoaderCursor.cs (1)
79cthd = Math.Max(1, (int)cblkMax);
DataLoadSave\Text\TextLoaderParser.cs (3)
1135return Math.Max(src, inputSize); 1175int ichEnd = Math.Min(ichLim, ichCur + 9); 1447for (int srcCur = Math.Max(min, fields.Count); srcCur < lim; srcCur++)
DataView\AppendRowsDataView.cs (1)
445newEnd = _batchEnd + (int)Math.Ceiling((double)_rowsLeft[i] * BatchSize / _totalLeft);
DataView\CacheDataView.cs (1)
1105_currMax = Math.Min(_perm.Length - 1, _curr + _batchMask);
Deprecated\Instances\HeaderSchema.cs (3)
91int size = Math.Min(count, Utils.Size(names)); 302int size = Math.Min(Utils.Size(names), count); 380int size = Math.Min(names.Length, count);
Deprecated\Vector\VectorUtils.cs (2)
139var absValue = Math.Abs(value); 373(slot, val1, val2) => res += Math.Abs(val1 - val2));
Evaluators\AnomalyDetectionEvaluator.cs (2)
331var maxNumFalsePos = (int)Math.Ceiling(max); 407_maxNumFalsePos = (int)Math.Ceiling(max);
Evaluators\BinaryClassifierEvaluator.cs (4)
669logloss = -Math.Log(prob, 2); 672logloss = -Math.Log(1.0 - prob, 2); 1236return -Math.Log(prob, 2); 1237return -Math.Log(1.0 - prob, 2);
Evaluators\ClusteringEvaluator.cs (3)
266nmi += pxy * Math.Log(pxy / (px * py)); 269entropy += -px * Math.Log(px); 308maxi = Math.Max(maxi, num / denom);
Evaluators\EvaluatorUtils.cs (6)
1307vectorStdevMetrics[j] = Math.Sqrt(agg[iMetric + j].SumSq / numFolds - vectorMetrics[j] * vectorMetrics[j]); 1329dvBldr.AddColumn(agg[iMetric].Name, NumberDataViewType.Double, avg, Math.Sqrt(agg[iMetric].SumSq / numFolds - avg * avg)); 1401int numConfusionTableLabels = sample < 0 ? labelNames.Length : Math.Min(labelNames.Length, sample); 1553Math.Sqrt(sumSqMetrics[i] / numFolds - avg * avg))); 1610rowDigitLen = Math.Max(confusionMatrix.PredictedClassesIndicators.Count - 1, 0).ToString().Length; 1618int paddingLen = Math.Max(9, rowLabelLen);
Evaluators\MulticlassClassificationEvaluator.cs (9)
304entropy += _sumWeightsOfClass[i] * Math.Log(_sumWeightsOfClass[i] / _numInstances); 474float p = Math.Min(1, Math.Max(Epsilon, _scoresArr[intLabel])); 475logloss = -Math.Log(p); 480logloss = -Math.Log(Epsilon); 796float p = Math.Min(1, Math.Max(Epsilon, scoresArr[intLabel])); 797dst = -Math.Log(p); 801dst = -Math.Log(Epsilon);
Evaluators\MultiOutputRegressionEvaluator.cs (3)
220res[i] = Math.Sqrt(_l2Loss[i] / _sumWeights); 259Double currL1Loss = Math.Abs((Double)label[i] - score[i]); 268_sumEuclidean += Math.Sqrt(l2) * weight;
Evaluators\QuantileRegressionEvaluator.cs (4)
103res[i.Key] = Math.Sqrt(i.Value / SumWeights); 151var diff = Math.Abs((Double)label - scoreValues[i]); 163var diff = Math.Abs((Double)label - scoreValues[i]); 409l1Editor.Values[s.Key] = Math.Abs(lab - s.Value);
Evaluators\RankingEvaluator.cs (2)
972discountMap[i] = 1 / Math.Log(2 + i); 1005int maxTrunc = Math.Min(truncationLevel, queryLabels.Count);
Evaluators\RegressionEvaluator.cs (4)
97return SumWeights > 0 ? Math.Sqrt(TotalL2Loss / SumWeights) : 0; 119Double currL1Loss = Math.Abs((Double)label - score); 305dst = Math.Abs((Double)label - score); 315dst = Math.Abs((Double)label - score);
Prediction\Calibrator.cs (6)
1380_data = new DataItem[Math.Min(4, capacity)]; 1396Array.Sort(_data, 0, Math.Min(_itemsSeen, _capacity), comp); 1507offset = Math.Log((prior0 + 1) / (prior1 + 1)); 1590logp = Math.Log(p); 1592log1p = Math.Log(1 - p); 1780return (float)(1 / (1 + Math.Exp(a * output + b)));
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))));
Transforms\RowShufflingTransformer.cs (1)
659int circularSwapIndex = (_rand.Next(Math.Min(_liveCount, _poolRows)) + _circularIndex) % _pipeIndices.Length;
Transforms\SkipTakeFilter.cs (2)
202return Math.Min(Math.Max(0, afterSkip), _take);
Transforms\SlotsDroppingTransformer.cs (4)
370slotsMax[iDst] = Math.Max(slotsMax[iDst], slotsMax[j]); 403slotsMax[i][iDst] = Math.Max(slotsMax[i][iDst], slotsMax[i][j]); 545type = new VectorDataViewType(vectorType.ItemType, Math.Max(dstLength, 1)); 841var type = new VectorDataViewType(vectorType.ItemType, Math.Max(dstLength, 1));
Utilities\SlotDropper.cs (3)
63int dstLength = srcLength - _lengthReduction[index] + Math.Max(SlotsMax[index] - srcLength + 1, 0); 133var lim = Math.Min(SlotsMin[i], src.Length); 153var newCount = Math.Min(srcValues.Length, newLength);
Utilities\TimerScope.cs (1)
45elapsedSeconds = Math.Round(elapsedSeconds);
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));
Utils\SequencePool.cs (8)
82int ibit = Utils.IbitHigh((uint)Math.Max(_idLim, 31)); 90_hash = new uint[Math.Max(_idLim, 10)]; 91_next = new int[Math.Max(_idLim, 10)]; 134Contracts.Assert(0 <= _idLim && Math.Max(10, _idLim) <= Utils.Size(_start) - 1); 135Contracts.Assert(Math.Max(10, _idLim) <= Utils.Size(_hash)); 136Contracts.Assert(Math.Max(10, _idLim) <= Utils.Size(_next)); 138Contracts.Assert(0 <= _start[_idLim] && Math.Max(40, _start[_idLim]) <= Utils.Size(_bytes)); 260long newSize = Math.Max((long)_bytes.Length + _bytes.Length / 2, ibLim + cbMax);
Microsoft.ML.Ensemble (2)
Selector\DiversityMeasure\RegressionDisagreementDiversityMeasure.cs (1)
20return Math.Abs(valueX - valueY);
Trainer\EnsembleTrainerBase.cs (1)
134validationDataSetProportion = Math.Max(validationDataSetProportion, stackingTrainer.ValidationDatasetProportion);
Microsoft.ML.Fairlearn (4)
Metrics\FairlearnMetricCatalog.cs (4)
246diffDict.Add("RSquared", Math.Abs((double)groupMetrics["RSquared"].Max() - (double)groupMetrics["RSquared"].Min())); 247diffDict.Add("RMS", Math.Abs((double)groupMetrics["RMS"].Max() - (double)groupMetrics["RMS"].Min())); 248diffDict.Add("MSE", Math.Abs((double)groupMetrics["MSE"].Max() - (double)groupMetrics["MSE"].Min())); 249diffDict.Add("MAE", Math.Abs((double)groupMetrics["MAE"].Max() - (double)groupMetrics["MAE"].Min()));
Microsoft.ML.FastTree (129)
BinFile\BinFinder.cs (1)
161binUpperBounds = new double[Math.Max(1, numValues)];
Dataset\Dataset.cs (2)
578if (Math.Abs(fraction.Sum() - 1.0) > 1e-6) 754int maxTrunc = Math.Min(trunc, boundaries[q + 1] - boundaries[q]);
Dataset\FeatureFlock.cs (22)
213featureFirstUsePenalty : featureReusePenalty * Math.Log(featureUseCount[feature] + 1); 301double entropyGain = (totalCount * Math.Log(totalCount) - lteCount * Math.Log(lteCount) - gtCount * Math.Log(gtCount)); 325double erfcArg = Math.Sqrt((bestShiftedGain - gainShift) * (totalCount - 1) / (2 * leafSplitCandidates.VarianceTargets * totalCount)); 366: featureReusePenalty * Math.Log(featureUseCount[firstFlockFeature] + 1); 444double entropyGain = (totalCount * Math.Log(totalCount) - lteCount * Math.Log(lteCount) - 445gtCount * Math.Log(gtCount)); 484double erfcArg = Math.Sqrt((bestShiftedGain - gainShift) * (totalCount - 1) / (2 * leafSplitCandidates.VarianceTargets * totalCount)); 535double minDocs = Math.Max(learner.MinDocsForCategoricalSplit, 586: featureReusePenalty * Math.Log(featureUseCount[firstFlockFeature] + 1); 649double entropyGain = (totalCount * Math.Log(totalCount) - lteCount * Math.Log(lteCount) - 650gtCount * Math.Log(gtCount)); 696double erfcArg = Math.Sqrt((bestShiftedGain - gainShift) * (totalCount - 1) / (2 * leafSplitCandidates.VarianceTargets * totalCount)); 731double minDocs = Math.Max(learner.MinDocsForCategoricalSplit, 808: featureReusePenalty * Math.Log(featureUseCount[firstFlockFeature] + 1); 871double entropyGain = (totalCount * Math.Log(totalCount) - lteCount * Math.Log(lteCount) - 872gtCount * Math.Log(gtCount)); 918double erfcArg = Math.Sqrt((bestShiftedGain - gainShift) * (totalCount - 1) / (2 * leafSplitCandidates.VarianceTargets * totalCount));
Dataset\IntArray.cs (4)
325long sparseBits = (long)(Math.Max((int)classicBits, 8) + 8) * (long)(Length - zerocount + zoverflows); 342long bestCost = Math.Min(Math.Min(Math.Min(denseBits, sparseBits), rleBits), segBits);
FastTree.cs (5)
3154double normFactor = max == 0 ? 1.0 : (1.0 / Math.Sqrt(max)); 3160yield return new KeyValuePair<string, double>(name, Math.Sqrt(pair.Value) * normFactor); 3236var numFeatures = Math.Max(NumFeatures, MaxSplitFeatIdx + 1); 3247double normFactor = max == 0 ? 1.0 : (1.0 / Math.Sqrt(max)); 3251bldr.AddFeature(pair.Key, (float)(Math.Sqrt(pair.Value) * normFactor));
FastTreeClassification.cs (2)
389double response = label * _sigmoidParameter / (1.0 + Math.Exp(label * _sigmoidParameter * pScores[i])); 390double absResponse = Math.Abs(response);
FastTreeRanking.cs (5)
674_sigmoidTable[i] = 2.0 - 2.0 / (1.0 + Math.Exp(-2.0 * sigmoidParam * score)); 676_sigmoidTable[i] = 2.0 / (1.0 + Math.Exp(2.0 * sigmoidParam * score)); 897Math.Abs((pDiscount[i] - pDiscount[j])) * 915double normFactor = (10 * Math.Log(1 + lambdaSum)) / lambdaSum; 955_discount[d] = 1.0 / Math.Log(2.0 + d);
FastTreeTweedie.cs (9)
398_maxClamp = Math.Abs(options.MaximumTreeOutput); 421denom += w * Math.Exp(s); 431num += w * _labels[i] * Math.Exp(_index1 * s); 432denom += w * Math.Exp(_index2 * s); 436var step = shrinkage * (Math.Log(num) - Math.Log(denom)); 467Gradient[i] = Math.Exp(Scores[i]) - _labels[i]; 476Gradient[i] = Math.Exp(_index2 * Scores[i]) - _labels[i] * Math.Exp(_index1 * Scores[i]);
GamClassification.cs (2)
122var actions = new Action[(int)Math.Ceiling(1.0 * targets.Length / innerLoopSize)]; 127var toDoc = Math.Min(d + innerLoopSize, targets.Length);
GamTrainer.cs (3)
190_gainConfidenceInSquaredStandardDeviations = Math.Pow(ProbabilityFunctions.Probit(1 - (1 - GamTrainerOptions.GainConfidenceLevel) * 0.5), 2); 214_gainConfidenceInSquaredStandardDeviations = Math.Pow(ProbabilityFunctions.Probit(1 - (1 - GamTrainerOptions.GainConfidenceLevel) * 0.5), 2); 631return -4.0 * (Math.Abs(sumTargets) + sumWeights);
SumupPerformanceCommand.cs (7)
115double denom = Math.Log(1 - _param); 138int numZeros = (int)Math.Min(Math.Floor(Math.Log(r) / denom), remaining); 188double denom = Math.Log(1 - p); 207yield return Math.Floor(Math.Log(r) / denom);
Training\Applications\ObjectiveFunction.cs (2)
63var actions = new Action[(int)Math.Ceiling((double)Dataset.NumQueries / QueryThreadChunkSize)]; 74GetGradientChunk(start, start + Math.Min(QueryThreadChunkSize, Dataset.NumQueries - start), GradSamplingRate, sampleIndex, threadIndex);
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\DocumentPartitioning.cs (2)
71var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumDocs / innerLoopSize)]; 76var toDoc = Math.Min(docStart + innerLoopSize, dataset.NumDocs);
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]));
Training\OptimizationAlgorithms\OptimizationAlgorithm.cs (1)
122Ensemble.RemoveAfter(Math.Max(bestIteration, 0));
Training\ScoreTracker.cs (2)
175var actions = new Action[(int)Math.Ceiling(1.0 * Dataset.NumDocs / innerLoopSize)]; 180var toDoc = Math.Min(d + innerLoopSize, Dataset.NumDocs);
Training\StepSearch.cs (2)
31_historicStepSize = Math.Max(1.0, _minStepSize); 34private static readonly double _phi = (1.0 + Math.Sqrt(5)) / 2;
Training\Test.cs (10)
137return Math.Sqrt(RawValue / Factor); 541var actions = new Action[(int)Math.Ceiling(1.0 * Dataset.NumDocs / chunkSize)]; 546var endDoc = Math.Min(documentStart + chunkSize - 1, Dataset.NumDocs - 1); 555l1Error += weight * Math.Abs(error); 619var actions = new Action[(int)Math.Ceiling(1.0 * binaryLabels.Length / chunkSize)]; 624var endDoc = Math.Min(documentStart + chunkSize - 1, binaryLabels.Length - 1); 659var actions = new Action[(int)Math.Ceiling(1.0 * Dataset.NumDocs / chunkSize)]; 664var endDoc = Math.Min(documentStart + chunkSize - 1, Dataset.NumDocs - 1); 680double loss = Math.Log(1.0 + Math.Exp(-1.0 * _sigmoidParameter * (label ? 1 : -1) * scores[i]));
Training\TreeLearners\LeastSquaresRegressionTreeLearner.cs (6)
622double absSumTargets = Math.Abs(sumTargets); 776double entropyGain = (totalCount * Math.Log(totalCount) - lteCount * Math.Log(lteCount) - gtCount * Math.Log(gtCount)); 801FeatureFirstUsePenalty : FeatureReusePenalty * Math.Log(FeatureUseCount[feature] + 1); 804double erfcArg = Math.Sqrt((bestShiftedGain - gainShift) * (totalCount - 1) / (2 * varianceTargets * totalCount));
Training\WinLossCalculator.cs (2)
53var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumQueries / chunkSize)]; 61WinLossRangeWorkerChunkFromScores(dataset, labels, scores, result, start, Math.Min(dataset.NumQueries - start, chunkSize), threadIndex));
TreeEnsemble\InternalRegressionTree.cs (7)
570Math.Abs(_splitGain[node] - tree._splitGain[node]) > 1e-6)) 1382var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumDocs / innerLoopSize)]; 1387var toDoc = Math.Min(d + innerLoopSize, dataset.NumDocs); 1407var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumDocs / innerLoopSize)]; 1412var toDoc = Math.Min(d + innerLoopSize, dataset.NumDocs); 1430var actions = new Action[(int)Math.Ceiling(1.0 * docIndices.Length / innerLoopSize)]; 1435var toDoc = Math.Min(d + innerLoopSize, docIndices.Length);
TreeEnsemble\InternalTreeEnsemble.cs (4)
296var actions = new Action[(int)Math.Ceiling(1.0 * dataset.NumDocs / innerLoopSize)]; 303var toDoc = Math.Min(d + innerLoopSize, dataset.NumDocs); 331double normalizingFactor = normalize && maxValue != 0 ? Math.Sqrt(maxValue) : 1.0; 337fmap.GetName(pair.Key), Math.Pow(pair.Value, power) / normalizingFactor));
Utils\LinqExtensions.cs (2)
270double total = values.Sum(value => Math.Exp(value - max)); 282r -= Math.Exp(value - max);
Utils\VectorUtils.cs (3)
16sum /= Math.Sqrt(sum); 177return Math.Sqrt(sum / length); 320return Math.Sqrt(sum);
Microsoft.ML.GenAI.Core (3)
Module\Attention.cs (1)
185attnWeights = attnWeights / Math.Sqrt(this._headDim);
Module\NewGELUActivation.cs (2)
23using var result3 = Math.Sqrt(2.0 / Math.PI) * result2;
Microsoft.ML.GenAI.Phi (4)
Module\Phi2Attention.cs (1)
147attnWeights = attnWeights / Math.Sqrt(this._headDim);
Module\Phi3SuScaledRotaryEmbedding.cs (3)
72scalingFactor = Math.Sqrt(1 + Math.Log(scale) / Math.Log(this._originalMaxPositionEmbeddings));
Microsoft.ML.ImageAnalytics (4)
VectorToImageTransform.cs (4)
410imageData[ix++] = (byte)Math.Round(blue * scale - offset); 411imageData[ix++] = (byte)Math.Round(green * scale - offset); 412imageData[ix++] = (byte)Math.Round(red * scale - offset); 413imageData[ix++] = (byte)(ex.Alpha ? Math.Round(alpha * scale - offset) : 0);
Microsoft.ML.IntegrationTests (4)
DataTransformation.cs (3)
44var petalMagnitude = Math.Sqrt(petalWidth * petalWidth + petalLength * petalLength); 45var sepalMagnitude = Math.Sqrt(sepalWidth * sepalWidth + sepalLength * sepalLength); 214Assert.InRange(row.Features[i], (uint)0, (uint)Math.Pow(2, 31));
SchemaDefinitionTests.cs (1)
85dst.Features[2 * i + 1] = (float)Math.Log(src.Features[i]);
Microsoft.ML.KMeansClustering (13)
KMeansModelParameters.cs (1)
172float distance = Math.Max(0,
KMeansPlusPlusTrainer.cs (12)
282maxThreads = Math.Min(maxThreads, argNumThreads.Value); 284return Math.Max(1, maxThreads); 401probabilityWeight = Math.Min(probabilityWeight, distance); 770maxInstancesToAccelerate = Math.Max(0, (accelMemBudgetMb * 1024 * 1024 - clusterBytes) / bytesPerInstance); 1190public double AverageScoreDelta => Math.Abs(PreviousAverageScore - AverageScore); 1476long maxInstancesToAccelerate = Math.Max(0, (accelMemBudgetMb * 1024 * 1024 - bytesPerCluster * k) / bytesPerInstance); 1534if (Math.Abs(a - b) < FloatingPointErrorThreshold) 1541if (Math.Abs(a) > Math.Abs(b)) 1542relativeError = Math.Abs((a - b) / a); 1544relativeError = Math.Abs((a - b) / b); 1635double key = Math.Log(rand.NextDouble()) / weight;
Microsoft.ML.LightGbm (9)
LightGbmMulticlassTrainer.cs (2)
285minLabel = Math.Min(minLabel, labelColumn); 286maxLabel = Math.Max(maxLabel, labelColumn);
LightGbmTrainerBase.cs (7)
928estimateNonZeroCnt = Math.Max(1, estimateNonZeroCnt); 1010batchSize = Math.Max(batchSize, catMetaData.NumCol); 1019batchRow = Math.Max(1, batchRow); 1060esimateBatchRow = Math.Max(1, esimateBatchRow); 1221ret = Math.Max(ret, 5); 1222ret = Math.Min(ret, 50); 1238ret = Math.Min(ret, numRow);
Microsoft.ML.Mkl.Components (10)
ComputeLRTrainingStdThroughHal.cs (2)
57stdErrorValues[0] = (float)Math.Sqrt(invHessian[0]); 89stdErrorValues[i] = (float)Math.Sqrt(stdErrorValues[i]);
OlsLinearRegression.cs (5)
149private static Double ProbClamp(Double p) => Math.Max(0, Math.Min(p, 1)); 526standardErrors[i] = Math.Sqrt(s2 * standardErrors[i]); 883Contracts.CheckDecode(Math.Sign(param) == Math.Sign(tvalue));
SymSgdClassificationTrainer.cs (2)
776int numPassesForThisBatch = Math.Min(numPassesForABatch, _options.NumberOfIterations - iter - numFinalPassesToTrainThoroughly); 778numPassesForThisBatch = Math.Max(1, numPassesForThisBatch);
VectorWhitening.cs (1)
416eigValues[i] = MathUtils.Sqrt(Math.Max(0, eigValues[i]) + ex.Epsilon);
Microsoft.ML.PCA (2)
PcaTrainer.cs (1)
218int oversampledRank = Math.Min(_rank + _oversampling, dimension);
PcaTransformer.cs (1)
310oversampledRank[iinfo] = Math.Min(transformInfos[iinfo].Rank + columns[iinfo].Oversampling, transformInfos[iinfo].Dimension);
Microsoft.ML.Predictor.Tests (6)
CompareBaselines.cs (5)
273return Math.Abs(d1 - d2) / Math.Max(1, Math.Max(Math.Abs(d1), Math.Abs(d2)));
TestPredictors.cs (1)
741Assert.Equal(prob, 1 / (1 + Math.Exp(-score)), 0.000001);
Microsoft.ML.ResultProcessor (1)
ResultProcessor.cs (1)
982foldIdx += (int)(foldIdxExtra * Math.Pow(1000, j));
Microsoft.ML.Samples (17)
Dynamic\Trainers\BinaryClassification\Gam.cs (1)
174private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Trainers\BinaryClassification\GamWithOptions.cs (1)
181private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Trainers\BinaryClassification\PermutationFeatureImportance.cs (2)
53feature => Math.Abs(feature.AreaUnderRocCurve.Mean)) 118private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Trainers\BinaryClassification\PermutationFeatureImportanceLoadFromDisk.cs (2)
52feature => Math.Abs(feature.AreaUnderRocCurve.Mean)) 104private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Trainers\MulticlassClassification\PermutationFeatureImportance.cs (1)
55.OrderByDescending(feature => Math.Abs(feature.MicroAccuracy.Mean))
Dynamic\Trainers\MulticlassClassification\PermutationFeatureImportanceLoadFromDisk.cs (1)
63.OrderByDescending(feature => Math.Abs(feature.MicroAccuracy.Mean))
Dynamic\Trainers\Ranking\PermutationFeatureImportance.cs (1)
56.OrderByDescending(feature => Math.Abs(
Dynamic\Trainers\Ranking\PermutationFeatureImportanceLoadFromDisk.cs (1)
63.OrderByDescending(feature => Math.Abs(
Dynamic\Trainers\Regression\GamAdvanced.cs (1)
172private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Trainers\Regression\GamWithOptionsAdvanced.cs (1)
180private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Trainers\Regression\PermutationFeatureImportance.cs (1)
58.OrderByDescending(feature => Math.Abs(
Dynamic\Trainers\Regression\PermutationFeatureImportanceLoadFromDisk.cs (1)
65.OrderByDescending(feature => Math.Abs(
Dynamic\Transforms\CalculateFeatureContributionCalibrated.cs (1)
143private static double Sigmoid(double x) => 1.0 / (1.0 + Math.Exp(-1 * x));
Dynamic\Transforms\TimeSeries\DetectSeasonality.cs (2)
18var seasonalData = Enumerable.Range(0, 100).Select(x => new TimeSeriesData(Math.Sin(2 * Math.PI + x)));
Microsoft.ML.SearchSpace (6)
Option\ChoiceOption.cs (1)
85var idx = Convert.ToInt32(Math.Floor(value));
Option\UniformNumericOption.cs (5)
63var logMax = Math.Log(Max); 64var logMin = Math.Log(Min); 65var logX = Math.Log(x); 84var order = Math.Pow(Max / Min, value); 180var intValue = Convert.ToInt32(Math.Floor(param.AsType<double>()));
Microsoft.ML.SearchSpace.Tests (6)
SearchSpaceTest.cs (1)
372writer.WriteNumberValue(Math.Round(Convert.ToDecimal(value), 6));
UniformNumericOptionTests.cs (5)
65var sampleInputs = Enumerable.Range(0, 10).Select(i => Parameter.FromInt(Convert.ToInt32(Math.Pow(2, i)))); 83.All((x) => Math.Abs(x.Item1 - x.Item2) < 1e-5) 95sampleOutputs.Select((x, i) => (x.AsType<double>(), Math.Pow(2, i))) 96.All((x) => Math.Abs(x.Item1 - x.Item2) < 1e-5) 116var sampleInputs = Enumerable.Range(0, 10).Select(i => Parameter.FromDouble(Math.Pow(2, i)));
Microsoft.ML.StandardTrainers (102)
LdSvm\LdSvmModelParameters.cs (2)
254score += Math.Tanh(_sigma * (VectorUtils.DotProduct(in _thetaPrime[current], in src) + _biasThetaPrime[current])) * 259score += Math.Tanh(_sigma * (VectorUtils.DotProduct(in _thetaPrime[current], in src) + _biasThetaPrime[current])) *
LdSvm\LdSvmTrainer.cs (14)
212tanhThetaTx[i] = (float)Math.Tanh(gamma * (VectorUtils.DotProduct(in feat, in theta[i]) + biasTheta[i])); 241tempSum += Math.Abs(VectorUtils.DotProduct(in s, in theta[thetaIdx]) + biasTheta[thetaIdx]); 246gamma *= (float)Math.Pow(2.0, iter / (_options.NumberOfIterations / 10.0)); 284int sampleSize = Math.Max(1, (int)Math.Sqrt(data.Length)); 292float etaTW = (float)1.0 / (_options.LambdaW * (float)Math.Sqrt(iter + 1)); 293float etaTTheta = (float)1.0 / (_options.LambdaTheta * (float)Math.Sqrt(iter + 1)); 294float etaTThetaPrime = (float)1.0 / (_options.LambdaThetaprime * (float)Math.Sqrt(iter + 1)); 324var tanhDist = (float)Math.Tanh(gamma * (VectorUtils.DotProduct(in features, in theta[i]) + biasTheta[i])); 331localWt[l] = (float)Math.Tanh(_options.Sigma * (VectorUtils.DotProduct(in features, in thetaPrime[l]) + biasThetaPrime[l])); 531var sampleSize = Math.Max(1, (int)Math.Sqrt(Length)); 620var sampleSize = Math.Max(1, (int)Math.Sqrt(Length));
Optimizer\DifferentiableFunction.cs (11)
198int numIters = Math.Min((int)x.Length, 10); 199int maxDirCount = Math.Min((int)x.Length / 2, 100); 203int dirCount = Math.Min(n * 10, maxDirCount); 228float normDiff = Math.Abs(1 - numDeriv / dirDeriv); 233maxNormDiff = Math.Max(maxNormDiff, normDiff); 275float normDiff = Math.Abs(1 - numDeriv / dirDeriv); 314float normDiff = Math.Abs(1 - numDeriv / dirDeriv); 348float normDiff = Math.Abs(1 - numDeriv / dirDeriv); 360return (float)(Math.Sqrt(-2 * Math.Log(a)) * MathUtils.Cos(2 * Math.PI * b));
Optimizer\L1Optimizer.cs (3)
107(ind, value) => { if (ind >= _biasCount) res += Math.Abs(value); }); 109VBufferUtils.ForEachDefined(in input, (ind, value) => res += Math.Abs(value)); 157return -Math.Min(gradVal + _l1weight, 0);
Optimizer\LearningRateScheduler.cs (6)
195decayPower = Staircase ? (float)Math.Floor(decayPower) : decayPower; 196float decayedLearningRate = LearningRate * (float)Math.Pow(DecayRate, decayPower); 253float calculatedStep = (float)decaySteps * (float)Math.Ceiling((double)globalStep / (double)decaySteps); 254decayedLearningRate = (LearningRate - EndLearningRate) * ((float)Math.Pow((1 - (float)globalStep / calculatedStep), Power)) + EndLearningRate; 258float calculatedStep = Math.Min(globalStep, decaySteps); 259decayedLearningRate = (LearningRate - EndLearningRate) * ((float)Math.Pow((1 - calculatedStep / (float)decaySteps), Power)) + EndLearningRate;
Optimizer\LineSearch.cs (6)
102float t2 = Math.Sign(b.Step - a.Step) * MathUtils.Sqrt(t1 * t1 - a.Deriv * b.Deriv); 163return Math.Min(_step, MaxStep); 333return Math.Min(_step, MaxStep); 457double e = Math.Exp(x); 459return (float)(Math.Log(1 + 1.0 / e) + Math.Log(1 + e) - 0.5 * x);
Optimizer\OptimizationMonitor.cs (4)
252float val = avgImprovement / Math.Abs(value); 326_bestBoundOnMin = Math.Max(_bestBoundOnMin, newBoundOnMin); 327float val = (value - _bestBoundOnMin) / Math.Abs(value); 381float val = norm / Math.Abs(state.Value);
Optimizer\Optimizer.cs (5)
312return -Math.Min(gradVal, 0); 434else if (Math.Abs(curr.D) <= -c2) 514else if (Math.Abs(curr.D) <= -c2) 543double t2 = Math.Sign(p1.A - p0.A) * Math.Sqrt(t1 * t1 - p0.D * p1.D);
Optimizer\SgdOptimizer.cs (1)
345float beta = Math.Max(0, betaPR);
Standard\LinearPredictorUtils.cs (4)
46if (Math.Abs(value - 0) >= Epsilon) 113if (Math.Abs(value - 0) >= Epsilon) 211.Where(weight => Math.Abs(weight.Value) >= Epsilon) 212.OrderByDescending(kv => Math.Abs(kv.Value));
Standard\LogisticRegression\LbfgsPredictorBase.cs (1)
655int numNew = Math.Max(1, (int)NumGoodRows / 100);
Standard\LogisticRegression\LogisticRegression.cs (5)
200float label01 = Math.Min(1, Math.Max(label, 0)); 250VBufferUtils.ForEachDefined(in CurrentWeights, (ind, value) => { if (ind >= BiasCount) regLoss += Math.Abs(value); }); 254ch.Info("Residual Deviance: \t{0} (on {1} degrees of freedom)", deviance, Math.Max(NumGoodRows - numParams, 0)); 351var variance = weight / (2 + 2 * Math.Cosh(score));
Standard\LogisticRegression\MulticlassLogisticRegression.cs (3)
336VBufferUtils.ForEachDefined(in CurrentWeights, (ind, value) => { if (ind >= BiasCount) regLoss += Math.Abs(value); }); 351nullDeviance -= (float)(2 * _prior[iLabel] * Math.Log(_prior[iLabel] / WeightSum)); 850var orderedWeights = Weights[classNumber].Items().OrderByDescending(kv => Math.Abs(kv.Value));
Standard\ModelStatistics.cs (3)
346var pValue = 1.0f - (float)ProbabilityFunctions.Erf(Math.Abs(zScore / sqrt2)); 381pValueEditor.Values[i - 1] = 1 - (float)ProbabilityFunctions.Erf(Math.Abs(zScoreEditor.Values[i - 1] / sqrt2)); 424var pValue = 1 - (float)ProbabilityFunctions.Erf(Math.Abs(zScore / sqrt2));
Standard\MulticlassClassification\MulticlassNaiveBayesTrainer.cs (7)
399Math.Log(1 + ((double)labelOccuranceCount - featureHistogram[iLabel][iFeature])) - 400Math.Log(labelOccuranceCount + labelCount); 592logProb += Math.Log(featureCount + 1) - Math.Log(labelOccurrenceCount + _labelCount); 593absentFeatureLogProb += Math.Log(absentFeatureCount + 1) - Math.Log(labelOccurrenceCount + _labelCount); 608double logProb = Math.Log(labelOccurrenceCount / _totalTrainingCount);
Standard\MulticlassClassification\OneVersusAllTrainer.cs (1)
901score[i] = Math.Exp(scores[i]);
Standard\MulticlassClassification\PairwiseCouplingTrainer.cs (1)
449return pii / Math.Max(pii, sum - (_numClasses - 2) * pii);
Standard\Online\AveragedLinear.cs (1)
255PendingMultipliers += Math.Abs(biasUpdate);
Standard\Online\LinearSvm.cs (1)
243float normalizer = 1 / (MathUtils.Sqrt(_lambda) * VectorUtils.Norm(Weights) * Math.Abs(WeightsScale));
Standard\Online\OnlineLinear.cs (3)
195float absWeightsScale = Math.Abs(WeightsScale); 298float maxNorm = Math.Max(VectorUtils.MaxNorm(in state.Weights), Math.Abs(state.Bias));
Standard\SdcaBinary.cs (11)
141=> Math.Min(8, Math.Max(1, Environment.ProcessorCount / 2)); 690int maxIterations = (int)Math.Max(1, 500000 / count) * 3; 692maxIterations = Math.Max(2, Math.Max(1, maxIterations / numThreads) * numThreads); 706long expectedIterations = Math.Max(2, maxIterations / 2 / numThreads) * numThreads; 709float l2 = Math.Max(1e-06f, 20f / (expectedIterations * rowCount)); 873biasReg[0] = Math.Abs(l1IntermediateBias[0]) - l1Threshold > 0.0 874? l1IntermediateBias[0] - Math.Sign(l1IntermediateBias[0]) * l1Threshold 996Double l1Regularizer = l1Threshold * l2Const * (VectorUtils.L1Norm(in weights[0]) + Math.Abs(biasReg[0])); 2064Double loss = Math.Log(2); // for log loss, this is exact; for Hinge, it's a reasonable estimate
Standard\SdcaMulticlass.cs (5)
291biasReg[iClass] = Math.Abs(l1IntermediateBias[iClass]) - l1Threshold > 0.0 292? l1IntermediateBias[iClass] - Math.Sign(l1IntermediateBias[iClass]) * l1Threshold 321biasReg[label] = Math.Abs(intermediateBias) - l1Threshold > 0.0 322? intermediateBias - Math.Sign(intermediateBias) * l1Threshold 421weightsL1Norm += VectorUtils.L1Norm(in weights[iClass]) + Math.Abs(biasReg[iClass]);
Standard\SdcaRegression.cs (2)
171=> Math.Min(2, Math.Max(1, Environment.ProcessorCount / 2));
Standard\StochasticTrainerBase.cs (2)
48=> Math.Min(8, Math.Max(1, Environment.ProcessorCount / 2));
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;
Algorithms\NelderMead.cs (4)
127int numSweeps = Math.Min(maxSweeps, _dim + 1 - _simplexVertices.Count); 149numSweeps = Math.Min(maxSweeps, _dim + 1 - _simplexVertices.Count); 401int numPoints = Math.Min(maxSweeps, _dim); 419int numPoints = Math.Min(maxSweeps, _pendingSweepsNotSubmitted.Count);
Algorithms\SmacSweeper.cs (2)
95return _randomSweeper.ProposeSweeps(Math.Min(numOfCandidates, _args.NumberInitialPopulation - numRuns), previousRuns); 168ParameterSet[] eiChallengers = GreedyPlusRandomSearch(bestKParamSets, forest, (int)Math.Ceiling(numOfCandidates / 2.0F), previousRuns);
Algorithms\SweeperProbabilityUtils.cs (17)
32variance = Math.Max(variance, minVariance); 33return 1 / Math.Sqrt(2 * Math.PI * variance) * Math.Exp(-Math.Pow(x - mean, 2) / (2 * variance)); 39double ztrans = centered / (Math.Sqrt(variance) * Math.Sqrt(2)); 46return 1 / Math.Sqrt(2 * Math.PI) * Math.Exp(-Math.Pow(x, 2) / 2); 51return 0.5 * (1 + ProbabilityFunctions.Erf(x * 1 / Math.Sqrt(2))); 71rvs.Add(mu + sigma * Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2)); 88if (Math.Abs(1.0 - total) > 0.0001)
AsyncSweeper.cs (1)
250PrepareNextBatch(_results.GetRange(0, Math.Max(0, _numGenerated - _relaxation)));
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)));
SynthConfigRunner.cs (3)
90total += Math.Pow(val, 2) - 10 * Math.Cos(2 * Math.PI * val);
Microsoft.ML.Sweeper.Tests (1)
TestSweeper.cs (1)
661Assert.Equal(Math.Min(args.NumberInitialPopulation, maxInitSweeps), sweeps.Length);
Microsoft.ML.TensorFlow (1)
TensorflowTransform.cs (1)
614var d = numOfUnkDim > 0 ? Math.Pow(typeValueCount / valCount, 1.0 / numOfUnkDim) : 0;
Microsoft.ML.TestFramework (10)
BaseTestBaseline.cs (8)
636double allowedVariance = Math.Pow(10, -digitsOfPrecision); 639delta = Math.Round(delta, digitsOfPrecision); 654delta2 = Math.Round(expected - actual, digitsOfPrecision); 680double absValue = Math.Abs(value); 681double integralDigitCount = Math.Floor(Math.Log10(absValue) + 1); 683double scale = Math.Pow(10, integralDigitCount); 684return scale * Math.Round(value / scale, digitsOfPrecision);
DataPipe\TestDataPipeBase.cs (2)
989return FloatUtils.GetBits(x) == FloatUtils.GetBits(y) || Math.Abs(x - y) < DoubleEps; 997return FloatUtils.GetBits(x) == FloatUtils.GetBits(y) || Math.Abs(x - y) < SingleEps;
Microsoft.ML.Tests (13)
PermutationFeatureImportanceTests.cs (1)
254Assert.Equal(pfi[0].RootMeanSquaredError.StandardError, pfi[0].RootMeanSquaredError.StandardDeviation / Math.Sqrt(pfi[0].RootMeanSquaredError.Count));
Scenarios\Api\TestApi.cs (1)
244Assert.True(Math.Abs(retrievedFloat - valueFloat) < .000001);
Scenarios\ClusteringTests.cs (4)
40clusters[i] = new ClusteringData { Points = new float[2] { (float)Math.Cos(Math.PI * i * 2 / k), (float)Math.Sin(Math.PI * i * 2 / k) } };
TrainerEstimators\MatrixFactorizationTests.cs (2)
132double windowsAndMacTolerance = Math.Pow(10, -7); 133double linuxTolerance = Math.Pow(10, -5);
TrainerEstimators\TreeEstimators.cs (4)
672sum += Math.Exp((float)nativeResult1[j + i * _classNumber]); 676double prob = Math.Exp(nativeResult1[j + i * _classNumber]); 701sum += Math.Exp((float)nativeResult1[j + i * _classNumber]); 705double prob = Math.Exp(nativeResult1[j + i * _classNumber]);
Transformers\HashTests.cs (1)
369Assert.Equal(Math.Pow(2, 31), hashedCol.Type.GetItemType().GetKeyCount());
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]);
EigenUtils.cs (12)
21var n = (int)Math.Sqrt(count); 40eigenvalues[i] = eigenvalues[i] <= 0 ? (float)(0.0) : (float)Math.Sqrt(eigenvalues[i]); 45x = Math.Abs(x); 46y = Math.Abs(y); 54return y * (float)Math.Sqrt(1 + t * t); 59return x * (float)Math.Sqrt(1 + t * t); 65float xx = Math.Abs(x); 136scale += Math.Abs(d[k]); 160g = CopySign((float)Math.Sqrt(h), f); 360tst1 = Math.Abs(d[m]) + Math.Abs(d[m + 1]); 361tst2 = tst1 + Math.Abs(e[m]);
IidChangePointDetector.cs (2)
127InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogPowerMartigaleBettingFunc(1 - options.Confidence / 100, InternalTransform.PowerMartingaleEpsilon)); 130InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogMixtureMartigaleBettingFunc(1 - options.Confidence / 100));
PolynomialUtils.cs (10)
22return Math.Abs(x) <= _tol; 28var sqrtDelta = Math.Sqrt(Math.Abs(delta)); 157var temp = Math.Abs(Coefficients[i]); 236b = Math.Min(uLen, i + 1) - 1; 237a = i >= Math.Max(uLen, vLen) ? len - i : b + 1; 238c = Math.Max(0, i - uLen + 1); 343var k1 = Math.Abs(factors.ElementAt(0).Key); 344var k2 = Math.Abs(factors.ElementAt(factors.Count - 1).Key); 362ind = Math.Min(factors.Count - 1, ind);
RootCauseAnalyzer.cs (12)
378dst.Items[i].Score = GetFinalScore(scoreList[i].Surprise, Math.Abs(scoreList[i].ExplanatoryScore), beta); 617a = (1 - Math.Pow(2, -surprise)); 622b = (1 - Math.Pow(2, -ep)); 632double ep = anomalyPoint.Value - anomalyPoint.ExpectedValue == 0 ? 0 : Math.Abs((rootCausePoint.Value - rootCausePoint.ExpectedValue) / (anomalyPoint.Value - anomalyPoint.ExpectedValue)); 646if (Math.Abs(preTotal) < Math.Abs(parent) * _rootCauseThreshold) 651return Math.Abs(pre) / Math.Abs(current) > _anomalyPreDeltaThreshold; 656if (Math.Abs(total) < Math.Abs(parent) * _rootCauseThreshold) 720private double Log2(double val) => Double.IsNaN(val) ? 0 : Math.Log(val) / Math.Log(2);
SeasonalityDetector.cs (1)
192double threshold = randomnessValue / Math.Sqrt(timeSeriesLength);
SequentialAnomalyDetectionTransformBase.cs (12)
279return Math.Log(epsilon) + (epsilon - 1) * Math.Log(p); 294Double logP = Math.Log(p); 295return Math.Log(p * logP + 1 - p) - 2 * Math.Log(-logP) - logP; 443protected Double LatestMartingaleScore => Math.Exp(_logMartingaleValue); 484Double bandWidth = Math.Sqrt(2) * ((n == 1) ? 1 : Math.Sqrt(_sumSquaredDist) / n); 485bandWidth = Math.Max(bandWidth, 1e-6); 556rawScore = (float)Math.Abs(result.Values[1]); 574result.Values[2] = Math.Min(result.Values[2], 1 - result.Values[2]); 614result.Values[3] = Math.Exp(_logMartingaleValue);
SrCnnAnomalyDetectionBase.cs (3)
233score = Math.Min(score, 1); 234score = Math.Max(score, 0); 293return (float)(Math.Abs(mag - avgMag) / safeDivisor);
SrCnnEntireAnomalyDetector.cs (27)
507_minimumOriginValue = Math.Min(_minimumOriginValue, value); 508_maximumOriginValue = Math.Max(_maximumOriginValue, value); 514_std = Math.Sqrt((squareSum - (sum * sum) / values.Length) / values.Length); 566_magList[i] = Math.Sqrt(_fftRe[i] * _fftRe[i] + _fftIm[i] * _fftIm[i]); 569_magLogList[i] = Math.Log(_magList[i]); 582_spectralList[i] = Math.Exp(_magLogList[i] - _cumSumList[i]); 610_ifftMagList[i] = Math.Sqrt(_ifftRe[i] * _ifftRe[i] + _ifftIm[i] * _ifftIm[i]); 613AverageFilter(_ifftMagList, Math.Min(_ifftMagList.Length, _judgementWindowSize)); 614for (int i = 0; i <= Math.Min(length, _minimumScoreWindowSize); ++i) 616_cumSumList[i] = _cumSumList[Math.Min(length, _minimumScoreWindowSize) - 1]; 624score = Math.Min(score, _maximumScore); 625score = Math.Max(score, _minimumScore); 633var zscore = Math.Abs(values[i] - _mean) / _std; 705if (Math.Abs(safeDivisor) < _eps) 709return (Math.Abs(mag - avgMag) / safeDivisor); 779segments.Add(new Tuple<int, int>(start, Math.Max(start, cursor))); 882return Math.Max(Math.Min(expectedValue, value + boundMargin), value - boundMargin); 905int start = Math.Max(idx - step, 0); 906int end = Math.Min(data.Length - 1, idx + step); 920start = Math.Max(idx - step, 0); 921end = Math.Min(data.Length - 1, idx + step); 977int window = Math.Min(data.Length / 3, 512); 989trendSum += Math.Abs(_trends[i]); 1013_units[i] = averageTrendPart + Math.Abs(_trends[i]) * trendFraction; 1115if (Math.Floor(sensitivity) == sensitivity) 1135double distanceFactor = Math.Abs(exp - value) / unit;
SsaAnomalyDetectionBase.cs (2)
38return Math.Abs(actual - predicted); 48return predicted == 0 ? 0 : Math.Abs((actual - predicted) / predicted);
SsaChangePointDetector.cs (2)
137InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogPowerMartigaleBettingFunc(1 - options.Confidence / 100, InternalTransform.PowerMartingaleEpsilon)); 140InternalTransform.AlertThreshold = Math.Exp(InternalTransform.WindowSize * InternalTransform.LogMixtureMartigaleBettingFunc(1 - options.Confidence / 100));
STL\LocalRegression.cs (3)
98double range = Math.Max(leftRange, rightRange); 129double range = Math.Max(leftRange, rightRange); 205absErrors[i] = Math.Abs(error);
STL\Loess.cs (2)
136double abs = Math.Abs(value); 149double abs = Math.Abs(value);
TrajectoryMatrix.cs (7)
128_shouldFftUsed = _windowSize * _k > (3 + 3 * Math.Log(_seriesLength)) * _seriesLength; 156return (Single)(coeff * Math.Sign(re) * Math.Sqrt(re * re + im * im)); 522b = Math.Min(uLen, i + 1) - 1; 523a = i >= Math.Max(uLen, vLen) ? len - i : b + 1; 524c = Math.Max(0, i - uLen + 1); 619int a = Math.Min(ue - us + 1, ve - vs + 1);
Microsoft.ML.TimeSeries.Tests (2)
TimeSeriesDirectApi.cs (2)
1070Value = Math.Sin(2 * Math.PI + x),
Microsoft.ML.Tokenizers (14)
Model\CodeGenTokenizer.cs (3)
398int index = addPrefixSpace ? Math.Max(0, textSpanToEncode.Length - 1) : textSpanToEncode.Length; 991retIndex = addPrefixSpace ? Math.Max(0, charsConsumed - 1) : charsConsumed; 999return Math.Max(retIndex, 0);
Model\SentencePieceTokenizer.cs (2)
1683charPoolArray ??= ArrayPool<char>.Shared.Rent(Math.Max(len, 50)); 2025charPoolArray ??= ArrayPool<char>.Shared.Rent(Math.Max(len, 50));
Model\TiktokenTokenizer.cs (1)
841byte[] tmp = ArrayPool<byte>.Shared.Rent(Math.Max(utf8Bytes.Length * 2, requiredCapacity));
Model\Word.cs (4)
209int count = Math.Min(SymbolsCount, maxTokens); 224int count = Math.Min(SymbolsCount, maxTokens); 239int count = Math.Min(SymbolsCount, maxTokens); 253int count = Math.Min(SymbolsCount, maxTokens);
Tokenizer.cs (1)
237tokenCount = Math.Min(maxTokenCount, tokens.Tokens.Count);
Utils\Helpers.cs (1)
16T[] tmp = ArrayPool<T>.Shared.Rent(Math.Max(arrayPoolArray.Length * 2, requiredCapacity));
Utils\ValueStringBuilder.cs (2)
399int newCapacity = (int)Math.Max( 401Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
Microsoft.ML.Tokenizers.Data.Tests (1)
src\Common\tests\RetryHelper.cs (1)
15private static readonly Func<int, int> _defaultBackoffFunc = i => Math.Min(i * 100, 60_000);
Microsoft.ML.Tokenizers.Tests (10)
BpeTests.cs (1)
304for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
CodeGenTests.cs (1)
312for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
EnglishRobertaTests.cs (1)
317for (int i = 1; i < destinationBuffer.Length - 1; i += Math.Max(1, destinationBuffer.Length - 3)) // enough to test length 1, and destinationBuffer.Length - 2 only.
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.
src\Common\tests\RetryHelper.cs (1)
15private static readonly Func<int, int> _defaultBackoffFunc = i => Math.Min(i * 100, 60_000);
TiktokenTests.cs (1)
168for (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) };
AutoFormerV2\Attention.cs (3)
51this.scale = System.Math.Pow(keyChannels, -0.5); 80var offset = new Tuple<int, int>(Math.Abs(points[i][0] - points[j][0]), Math.Abs(points[i][1] - points[j][1]));
AutoFormerV2\AutoFormerV2Backbone.cs (1)
94outChannels: embedChannels[Math.Min(iLayer + 1, embedChannels.Count - 1)],
AutoFormerV2\BasicLayer.cs (2)
66int hp = (int)Math.Ceiling((double)h / this.windowSize) * this.windowSize; 67int wp = (int)Math.Ceiling((double)w / this.windowSize) * this.windowSize;
AutoFormerV2\ObjectDetectionMetrics.cs (4)
162float xleft = Math.Max(bbox.Left, gt.Left); 163float yleft = Math.Max(bbox.Top, gt.Top); 164float xright = Math.Min(bbox.Left + bbox.Width, gt.Left + gt.Width); 165float yright = Math.Min(bbox.Top + bbox.Height, gt.Top + gt.Height);
NasBert\Modules\ActivationFunction.cs (2)
64private readonly double _alpha = Math.Sqrt(2 / Math.PI);
NasBert\Modules\ConvSeparable.cs (1)
28var std = Math.Sqrt((4 * (1.0 - dropout)) / (kernelSize * inChannels));
NasBert\Modules\Embedding\LearnedPositionalEmbedding.cs (1)
28ModelUtils.InitNormal(Embedding.weight, mean: 0, std: Math.Pow(EmbeddingDim, -0.5));
NasBert\Modules\Embedding\SinusoidalPositionalEmbedding.cs (1)
38var embedDouble = Math.Log(10000) / (halfDim - 1);
NasBert\Modules\MultiHeadAttention.cs (4)
74_scaling = Math.Pow(_headDim, -0.5); 112ModelUtils.InitXavierUniform(QProjection.weight, 1.0 / Math.Sqrt(2.0)); 113ModelUtils.InitXavierUniform(KProjection.weight, 1.0 / Math.Sqrt(2.0)); 114ModelUtils.InitXavierUniform(VProjection.weight, 1.0 / Math.Sqrt(2.0));
NasBert\Optimizers\BaseOptimizer.cs (1)
65return Math.Sqrt(Parameters
Roberta\Modules\AttentionSelf.cs (1)
57queryLayer.div_(Math.Sqrt(AttentionHeadSize));
Microsoft.ML.Transforms (76)
Dracula\CMCountTable.cs (1)
237: base(Math.Max(labelCardinality, table.LabelCardinality))
Dracula\DictCountTable.cs (1)
182: base(Math.Max(labelCardinality, table.LabelCardinality))
Dracula\Featurizer.cs (1)
204logOdds[i] = (float)Math.Log(
Expression\BuiltinFunctions.cs (63)
163FunctionProviderUtils.Fn<I4, I4>(Math.Abs), 164FunctionProviderUtils.Fn<I8, I8>(Math.Abs), 165FunctionProviderUtils.Fn<R4, R4>(Math.Abs), 166FunctionProviderUtils.Fn<R8, R8>(Math.Abs)); 176FunctionProviderUtils.Fn<R8, R8>(Math.Exp)); 180FunctionProviderUtils.Fn<R8, R8>(Math.Log)); 184FunctionProviderUtils.Fn<R8, R8>(Math.Log), 186FunctionProviderUtils.Fn<R8, R8, R8>(Math.Log)); 218FunctionProviderUtils.Fn<R8, R8>(Math.Tan)); 227FunctionProviderUtils.Fn<R8, R8>(Math.Asin)); 231FunctionProviderUtils.Fn<R8, R8>(Math.Acos)); 235FunctionProviderUtils.Fn<R8, R8>(Math.Atan)); 245FunctionProviderUtils.Fn<R8, R8>(Math.Sinh)); 249FunctionProviderUtils.Fn<R8, R8>(Math.Cosh)); 253FunctionProviderUtils.Fn<R8, R8>(Math.Tanh)); 258FunctionProviderUtils.Fn<R8, R8>(Math.Sqrt)); 264FunctionProviderUtils.Fn<R8, R8>(Math.Truncate)); 268FunctionProviderUtils.Fn<R8, R8>(Math.Floor)); 273FunctionProviderUtils.Fn<R8, R8>(Math.Ceiling)); 277FunctionProviderUtils.Fn<R8, R8>(Math.Round)); 281FunctionProviderUtils.Fn<I4, I4, I4>(Math.Min), 282FunctionProviderUtils.Fn<I8, I8, I8>(Math.Min), 283FunctionProviderUtils.Fn<R4, R4, R4>(Math.Min), 284FunctionProviderUtils.Fn<R8, R8, R8>(Math.Min)); 287FunctionProviderUtils.Fn<I4, I4, I4>(Math.Max), 288FunctionProviderUtils.Fn<I8, I8, I8>(Math.Max), 289FunctionProviderUtils.Fn<R4, R4, R4>(Math.Max), 290FunctionProviderUtils.Fn<R8, R8, R8>(Math.Max)); 427return Math.PI; 509return (R4)Math.Pow(a, b); 515return (R4)Math.Exp(a); 521return (R4)Math.Log(a); 527return (R4)Math.Log(a, b); 533return (R4)(a * (180 / Math.PI)); 539return a * (180 / Math.PI); 545return (R4)(a * (Math.PI / 180)); 551return a * (Math.PI / 180); 557return (R4)Math.Sin(a); 569return (R4)Math.Sin(a * (Math.PI / 180)); 575return MathUtils.Sin(a * (Math.PI / 180)); 581return (R4)Math.Cos(a); 593return (R4)Math.Cos(a * (Math.PI / 180)); 599return MathUtils.Cos(a * (Math.PI / 180)); 605return (R4)Math.Tan(a); 611return (R4)Math.Tan(a * (Math.PI / 180)); 617return Math.Tan(a * (Math.PI / 180)); 623return (R4)Math.Asin(a); 629return (R4)Math.Acos(a); 635return (R4)Math.Atan(a); 645return (R4)Math.Atan2(a, b); 655return Math.Atan2(a, b); 661return (R4)Math.Sinh(a); 667return (R4)Math.Cosh(a); 673return (R4)Math.Tanh(a); 679return (R4)Math.Sqrt(a); 685return (R4)Math.Truncate(a); 691return (R4)Math.Floor(a); 697return (R4)Math.Ceiling(a); 703return (R4)Math.Round(a);
Expression\CodeGen.cs (1)
661CallBin<R8>(Math.Pow);
Expression\LambdaBinder.cs (2)
809return Math.Pow(v1, v2); 1415args[i] = Convert(node.Args.Items[i].AsExpr, best.Kinds[Math.Min(i, ivMax)]);
LearnerFeatureSelection.cs (3)
147var score = Math.Abs(scoresValues[i]); 163score = Math.Abs(scoresValues[i]); 238var score = Math.Abs(scores[i]);
MutualInformationFeatureSelection.cs (1)
714score += _contingencyTable[i][j] / (double)_labels.Length * Math.Log(_contingencyTable[i][j] * (double)_labels.Length / ((double)_labelSums[i] * _featureSums[j]), 2);
RandomFourierFeaturizing.cs (1)
195RotationTerms[i] = (_rand.NextSingle() - (float)0.5) * (float)Math.PI;
Text\NgramTransform.cs (1)
306invDocFreqs[iinfo][i] = Math.Log(totalDocs / invDocFreqs[iinfo][i]);
Text\WordEmbeddingsExtractor.cs (1)
680int skippedLinesCount = Math.Max(1, _linesToSkip);
Microsoft.ML.Vision (2)
DnnRetrainTransform.cs (1)
817var d = numOfUnkDim > 0 ? Math.Pow(typeValueCount / valCount, 1.0 / numOfUnkDim) : 0;
ImageClassificationTrainer.cs (1)
253MinDelta = Math.Abs(minDelta);
Microsoft.VisualBasic.Core (9)
Microsoft\VisualBasic\CompilerServices\LikeOperator.vb (1)
1543SourceIndex = Math.Max(SourceIndex, PatternGroups(PGIndex).MinSourceIndex + 1)
Microsoft\VisualBasic\CompilerServices\VBBinder.vb (5)
1164For ParmIndex = 0 To Math.Min(LastArgIndexToCheck, ParamArrayIndex) - 1 1313For ParmIndex = 0 To Math.Min(ArgCountUpperBound, Math.Max(LastNonSetValueIndex0, LastNonSetValueIndex1)) 1785For ParmIndex = 0 To Math.Max(LastArgNonSetValueIndex, LastParamNonSetValueIndex) 1858Dim ArrayUBound As Integer = Math.Max(vars.GetUpperBound(0), paramOrder.GetUpperBound(0))
Microsoft\VisualBasic\ErrObject.vb (1)
113ElseIf System.String.CompareOrdinal("Exception from HRESULT: 0x", 0, Msg, 0, Math.Min(Msg.Length, 26)) = 0 Then
Microsoft\VisualBasic\FileIO\FileSystem.vb (1)
1300Dim BufferSize As Integer = Math.Max(MaxByteDetectedEncoding, DEFAULT_BUFFER_SIZE)
Microsoft\VisualBasic\Financial.vb (1)
5Imports System.Math
Microsoft.VisualStudio.LanguageServices (17)
Diagnostics\VisualStudioVenusSpanMappingService.cs (1)
60sourceSpan = TextSpan.FromBounds(startPos, Math.Max(startPos, endPos));
DocumentOutline\DocumentOutlineView.xaml.cs (1)
342var croppedRenderWidth = Math.Min(item.RenderSize.Width, SymbolTree.RenderSize.Width / 4);
Extensions\DocumentExtensions.cs (1)
55var end = Math.Max(start, previousLine.End);
FindReferences\Entries\DocumentSpanEntry.cs (2)
236var firstLineNumber = Math.Max(0, lineNumber - AdditionalLineCountPerSide); 237var lastLineNumber = Math.Min(sourceText.Lines.Count - 1, lineNumber + AdditionalLineCountPerSide);
MoveStaticMembers\TypeNameItem.cs (1)
54for (var i = 0; i < Math.Min(xnames.Length, ynames.Length); i++)
Packaging\PackageInstallerServiceFactory.cs (1)
640for (int i = 0, n = Math.Min(split1.Length, split2.Length); i < n; i++)
ProjectSystem\MetadataReferences\VisualStudioMetadataReferenceManager.cs (1)
256while ((read = source.Read(buffer, 0, Math.Min(left, buffer.Length))) != 0)
StackTraceExplorer\StackFrameViewModel.cs (1)
128lineNumber = Math.Min(sourceText.Lines.Count, lineNumber);
SymbolSearch\VisualStudioSymbolSearchService.cs (2)
192bestRank = bestRank == null ? rank : Math.Max(bestRank.Value, rank); 194if (rank < RankThreshold && Math.Abs(bestRank.Value - rank) > 1)
Venus\CodeBlockEnumerator.cs (1)
45pceltFetched = Math.Min(celt, (uint)(_codeBlocks.Count - _currentElement));
Venus\ContainedDocument.cs (1)
1032var ch = char.ToLower(surfaceSnapshot[Math.Max(surfacePoint.Value - 1, 0)]);
Venus\ContainedDocument.DocumentServiceProvider.cs (2)
308var startLine = line.Snapshot.GetLineFromLineNumber(Math.Max(0, line.LineNumber - AdditionalLineCountPerSide)); 309var endLine = line.Snapshot.GetLineFromLineNumber(Math.Min(line.Snapshot.LineCount - 1, line.LineNumber + AdditionalLineCountPerSide));
Workspace\VisualStudioDocumentNavigationService.cs (2)
349=> Math.Min(documentLength, Math.Max(position, 0));
Microsoft.VisualStudio.LanguageServices.CSharp (1)
CodeModel\CSharpCodeModelService.cs (1)
1372lengthToStrip = Math.Min(lengthToStrip, line.GetLeadingWhitespace().Length);
Microsoft.VisualStudio.LanguageServices.CSharp.UnitTests (1)
PersistentStorage\AbstractPersistentStorageTests.cs (1)
84ThreadPool.SetMinThreads(Math.Max(workerThreads, NumThreads), completionPortThreads);
MSBuild (6)
CommunicationsUtilities.cs (1)
522timeout = Math.Max(timeout, 50);
FileUtilities.cs (1)
397var headingSegmentsToRemove = Math.Max(0, segments.Length - trailingSegmentsToKeep);
NodeEndpointOutOfProcBase.cs (1)
365int waitTimeRemaining = Math.Max(0, CommunicationsUtilities.NodeConnectionTimeout - (int)usedWaitTime.TotalMilliseconds);
TerminalLogger\NodesFrame.cs (1)
29Width = Math.Min(width, MaxColumn);
TerminalLogger\Terminal.cs (1)
156ReadOnlySpan<char> truncatedText = text.Slice(0, Math.Min(text.Length, Width - 1));
TerminalLogger\TerminalLogger.cs (1)
1270int length = Math.Min(maxLength - indent.Length, text.Length - start);
MSBuildTaskHost (3)
Concurrent\ConcurrentDictionary.cs (1)
440_budget = Math.Max(1, newBuckets.Length / newLocks.Length);
Concurrent\ConcurrentQueue.cs (1)
112int nextSize = tail._preservedForObservation != 0 ? InitialSegmentLength : Math.Min(tail.Capacity * 2, MaxSegmentLength);
NodeEndpointOutOfProcBase.cs (1)
365int waitTimeRemaining = Math.Max(0, CommunicationsUtilities.NodeConnectionTimeout - (int)usedWaitTime.TotalMilliseconds);
mscorlib (1)
src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
360[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Math))]
netstandard (1)
netstandard.cs (1)
1049[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Math))]
PresentationBuildTasks (4)
MS\Internal\MarkupCompiler\VersionHelper.cs (1)
205int build = Math.Min(ushort.MaxValue, (int)days.TotalDays);
src\Microsoft.DotNet.Wpf\src\PresentationCore\MS\Internal\Media\XamlSerializationHelper.cs (1)
431scaledInteger = Math.Floor( scaledValue ) ;
src\Microsoft.DotNet.Wpf\src\PresentationCore\System\Windows\Media\ParsersCommon.cs (2)
365_curIndex = Math.Min(_curIndex+8, _pathLength); // "Infinity" has 8 characters 375_curIndex = Math.Min(_curIndex+3, _pathLength); // "NaN" has 3 characters
PresentationCore (524)
MS\Internal\AnimatedTypeHelpers.cs (17)
370return Math.Abs((Int32)to - (Int32)from); 387return Math.Abs(to.ScA - from.ScA) 388+ Math.Abs(to.ScR - from.ScR) 389+ Math.Abs(to.ScG - from.ScG) 390+ Math.Abs(to.ScB - from.ScB); 398return (Double)Math.Abs(to - from); 403return Math.Abs(to - from); 408return Math.Abs(to - from); 413return Math.Abs(to - from); 418return Math.Abs(to - from); 440return Math.Abs((to - from).Length); 445return Math.Abs((to - from).Length); 465return Math.Sqrt((a * a) + (b * b)); 475return Math.Abs(to - from); 480return Math.Abs(((System.Windows.Vector)to - (System.Windows.Vector)from).Length); 497return Math.Abs((to - from).Length); 502return Math.Abs((to - from).Length);
MS\Internal\FontCache\FontCacheUtil.cs (1)
723int minLength = Math.Min(aLength, bLength);
MS\Internal\FontCache\FontFaceLayoutInfo.cs (2)
918int smaller = Math.Min(lastChar, firstChar); 919int larger = Math.Max(lastChar, firstChar);
MS\Internal\Generic\Span.cs (1)
506_cp = Math.Min(cp, _dcp);
MS\Internal\IListConverters.cs (4)
99List<double> list = new List<double>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1)); 142List<ushort> list = new List<ushort>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1)); 183List<bool> list = new List<bool>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1)); 225List<Point> list = new List<Point>(Math.Min(256, value.Length / EstimatedCharCountPerItem + 1));
MS\Internal\Ink\Bezier.cs (5)
384bool accept = (Math.Abs(det) > Math.Abs(s) * DoubleUtil.DBL_EPSILON && 385Math.Abs(det) > Math.Abs(u) * DoubleUtil.DBL_EPSILON); 532nPoints = (int)(Math.Sqrt(rCurv / tolerance)) + 3;
MS\Internal\Ink\CuspData.cs (4)
468rMin = Math.Min(rMin, a); 469rMax = Math.Max(a, rMax); 497_dist = Math.Abs(rR) + Math.Abs(rB);
MS\Internal\Ink\EllipticalNodeOperations.cs (12)
30_radius = Math.Max(_radii.Width, _radii.Height); 117double distance = Math.Sqrt(distanceSquared); 138rad *= Math.Sqrt(1 - rSinSquared); 139spine *= Math.Sqrt(rSinSquared); 618radius = Math.Abs(nearest.Y); 622radius = Math.Abs(nearest.X); 721double tmp = Math.Sqrt(B*B-4.0f * A * C); 728findex = Math.Min(s1, s2); 755findex = Math.Abs(Math.Min(s1, s2) - 0d) < Math.Abs(Math.Max(s1, s2) - 1d) ? 0d : 1d;
MS\Internal\Ink\ErasingStroke.cs (2)
183Math.Min(lastFragment.BeginFIndex, fragment.BeginFIndex), 184Math.Max(lastFragment.EndFIndex, fragment.EndFIndex));
MS\Internal\Ink\InkSerializedFormat\GorillaCodec.cs (8)
148uint ulAbsMaxDelDel = (uint)Math.Max(MathHelper.AbsNoThrow(minDelDel), MathHelper.AbsNoThrow(maxDelDel)); 150uint ulAbsMax = (uint)Math.Max(MathHelper.AbsNoThrow(minVal), MathHelper.AbsNoThrow(maxVal)); 221maxByte = Math.Max(input[n], maxByte); 222maxShort = Math.Max((ushort)shortReader.ReadUInt16Reverse(Native.BitsPerShort), maxShort); 232maxByte = Math.Max(input[n], maxByte); 233maxShort = Math.Max((ushort)shortReader.ReadUInt16Reverse(Native.BitsPerShort), maxShort); 239maxByte = Math.Max(input[n], maxByte); 281ulAbsMax = (uint)Math.Max(MathHelper.AbsNoThrow(minInt), MathHelper.AbsNoThrow(maxInt));
MS\Internal\Ink\InkSerializedFormat\InkSerializer.cs (3)
1394double dAngle = (tdrd.Transform[0] / 100) * (Math.PI / 180); 1396M00 = M11 = Math.Cos(dAngle); 1397M01 = Math.Sin(dAngle);
MS\Internal\Ink\InkSerializedFormat\SerializationHelper.cs (1)
106ull = (ulong)Math.Abs(Value);
MS\Internal\Ink\Lasso.cs (6)
151DoubleUtil.GreaterThanOrClose(point.X, Math.Min(prevLassoPoint.X, lassoPoint.X)) && 152DoubleUtil.LessThanOrClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X))) 161if (DoubleUtil.GreaterThanOrClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X))) 166else if (DoubleUtil.GreaterThanOrClose(point.X, Math.Min(prevLassoPoint.X, lassoPoint.X))) 517return (Math.Abs(vector.X) < MinDistance && Math.Abs(vector.Y) < MinDistance);
MS\Internal\Ink\Renderer.cs (1)
560i = Math.Min(_visuals.Count, _strokes.Count); //not -1, we're about to decrement
MS\Internal\Ink\StrokeNode.cs (17)
776line1XMin = Math.Floor(line1Start.X); 777line1XMax = Math.Ceiling(line1End.X); 781line1XMin = Math.Floor(line1End.X); 782line1XMax = Math.Ceiling(line1Start.X); 787line2XMin = Math.Floor(line2Start.X); 788line2XMax = Math.Ceiling(line2End.X); 792line2XMin = Math.Floor(line2End.X); 793line2XMax = Math.Ceiling(line2Start.X); 798line1YMin = Math.Floor(line1Start.Y); 799line1YMax = Math.Ceiling(line1End.Y); 803line1YMin = Math.Floor(line1End.Y); 804line1YMax = Math.Ceiling(line1Start.Y); 809line2YMin = Math.Floor(line2Start.Y); 810line2YMax = Math.Ceiling(line2End.Y); 814line2YMin = Math.Floor(line2End.Y); 815line2YMax = Math.Ceiling(line2Start.Y); 1061double floor = Math.Floor(findex);
MS\Internal\Ink\StrokeNodeOperations.cs (2)
731double r = (Math.Abs(nextNode.X) < Math.Abs(nextNode.Y)) //DoubleUtil.IsZero(nextNode.X)
MS\Internal\Ink\StrokeNodeOperations2.cs (1)
507return Math.Sqrt(nearestOnFirst.LengthSquared / shortest.LengthSquared);
MS\Internal\Ink\StrokeRenderer.cs (27)
85double delta = Math.Abs(GetAngleDeltaFromLast(strokeNode.PreviousPosition, strokeNode.Position, ref lastAngle)); 105if ((Math.Min(prevArea, currArea) / Math.Max(prevArea, currArea)) <= 0.70d) 245double maxExtent = Math.Max(drawingAttributes.Height, drawingAttributes.Width); 246percentIntersect += Math.Min(4.99999d, ((maxExtent / 20d) * 5d)); 514bool directionChangedOverAbsoluteThreshold = Math.Abs(delta) > 90d && Math.Abs(delta) < (360d - 90d); 515bool directionChangedOverOverlapThreshold = overlap && !(ignorePressure || strokeNode.PressureFactor == 1f) && Math.Abs(delta) > 30d && Math.Abs(delta) < (360d - 30d); 524if ((Math.Min(prevArea, currArea) / Math.Max(prevArea, currArea)) <= 0.90d) 829double intersectLeft = Math.Max(rect1.Left, rect2.Left); 830double intersectTop = Math.Max(rect1.Top, rect2.Top); 831double intersectWidth = Math.Max((double)(Math.Min(rect1.Right, rect2.Right) - intersectLeft), (double)0); 832double intersectHeight = Math.Max((double)(Math.Min(rect1.Bottom, rect2.Bottom) - intersectTop), (double)0); 842double minArea = Math.Min(rect1Area, rect2Area); 1045angle = Math.PI / 2.0; 1049angle = Math.PI * 3.0 / 2.0; 1060angle = Math.PI; 1067angle = Math.Atan(dy / dx) + Math.PI; 1071angle = Math.Atan(dy / dx) + (2 * Math.PI); 1075angle = Math.Atan(dy / dx); 1080angle = angle * 180 / Math.PI;
MS\Internal\IO\Packaging\DeobfuscatingStream.cs (1)
290int bytesToXor = (int) (Math.Min(ObfuscatedLength, unchecked (readPosition + (long) count)) - readPosition);
MS\Internal\IO\Packaging\NetStream.cs (7)
146count = Math.Min(bytesAvailable, count); // don't return more than they requested, and don't return more than is available 734bytesAvailable = Math.Min(block.Length, (int)(data.End - block.Offset)); 899_length = (int)(Math.Max(_offset + _length, b._offset + b._length) - _offset); 956bytesAvailable = (int)Math.Min(block.Length, _highWaterMark - block.Offset); 1020dataAvailable = (int)Math.Min(block.Length, _highWaterMark - block.Offset); 1052dataAvailable = (int)Math.Min(block.Length, _highWaterMark - block.Offset); 1150block.Length = (int)Math.Min(block.Length, _fullStreamLength - block.Offset);
MS\Internal\Media\XamlSerializationHelper.cs (1)
431scaledInteger = Math.Floor( scaledValue ) ;
MS\Internal\Media3D\GeneralTransform2DTo3DTo2D.cs (19)
500if (!((Math.Max(visEdgeStart.X, visEdgeEnd.X) < Math.Min(uv1.X, uv2.X)) || 501(Math.Min(visEdgeStart.X, visEdgeEnd.X) > Math.Max(uv1.X, uv2.X)) || 502(Math.Max(visEdgeStart.Y, visEdgeEnd.Y) < Math.Min(uv1.Y, uv2.Y)) || 503(Math.Min(visEdgeStart.Y, visEdgeEnd.Y) > Math.Max(uv1.Y, uv2.Y)))) 604if (Math.Abs(visUV1.X - visUV2.X) > Math.Abs(visUV1.Y - visUV2.Y)) 918if (!((Math.Max(visEdgeStart.X, visEdgeEnd.X) < Math.Min(uv1.X, uv2.X)) || 919(Math.Min(visEdgeStart.X, visEdgeEnd.X) > Math.Max(uv1.X, uv2.X)) || 920(Math.Max(visEdgeStart.Y, visEdgeEnd.Y) < Math.Min(uv1.Y, uv2.Y)) || 921(Math.Min(visEdgeStart.Y, visEdgeEnd.Y) > Math.Max(uv1.Y, uv2.Y)))) 1088closestIntersection = ((currClosest - edges[i]._p1Transformed).Length / Math.Sqrt(denom) *
MS\Internal\Media3D\LineUtil.cs (4)
282maxvalue = Math.Max(maxvalue,m[i,j]*m[i,j]); 285maxvalue = Math.Sqrt(maxvalue); 334double root = Math.Sqrt(1+tau*tau); 337_c = 1/Math.Sqrt(1+t*t);
MS\Internal\Media3D\M3DUtil.cs (2)
375return radians*(180.0/Math.PI); 380return degrees*(Math.PI/180.0);
MS\Internal\Shaping\CompositeFontFamily.cs (2)
118return Math.Round(_fontInfo.Baseline * emSize); 149return Math.Round(_fontInfo.LineSpacing * emSize);
MS\Internal\Shaping\TypefaceMap.cs (4)
177cch = Math.Min(cch, itemSpanRider.Length); 178cch = Math.Min(cch, typefaceIndexSpanRider.Length); 222int cch = Math.Min(cchRange - ich, typefaceIndexSpanRider.Length); 388int cch = Math.Min(unicodeString.Length - ich, typefaceSpanRider.Length);
MS\Internal\TextFormatting\Bidi.cs (9)
1605lengthResolved = Math.Max(startOfNeutrals, startOfDelayed) == PositionInvalid ? 1607((Math.Min(startOfNeutrals, startOfDelayed) == PositionInvalid) ? 1608(Math.Max(startOfNeutrals, startOfDelayed)) : 1609(Math.Min(startOfNeutrals, startOfDelayed))); 1839cchText = Math.Min(cchText, index); 2405sor = Helper.IsOdd(Math.Max(baseLevel, levels[runStart])) ? 2410sor = Helper.IsOdd(Math.Max(lastRunLevel, levels[runStart])) ? 2420eor = Helper.IsOdd(Math.Max(levels[runStart], baseLevel)) ? 2435eor = Helper.IsOdd(Math.Max(levels[runStart], levels[runLimits[runNumber-1] + 1])) ?
MS\Internal\TextFormatting\FormatSettings.cs (3)
136_maxLineWidth = Math.Max(maxLineWidth, 0); 173formatWidth = Math.Max(formatWidth, 0); 174formatWidth = Math.Min(formatWidth, Constants.IdealInfiniteWidth);
MS\Internal\TextFormatting\FullTextLine.cs (5)
1369offsetToNextCaretStopIndex = Math.Min(Length, lsrun.Length - caretStopIndex + lsrun.OffsetToFirstCp + _cpFirst); 1411lscpVisisble = Math.Min(lscpVisisble, _metrics._lscpLim - 1); 1643int lscpEndInSubline = Math.Min( 1986int cch = Math.Min(plsrunSpanRider.Length, cchLeft); 2072cch = Math.Min(cch, cchLeft);
MS\Internal\TextFormatting\FullTextState.cs (1)
266return Math.Min(0, TextFormatterImp.RealToIdeal(_markerStore.Pap.TextMarkerProperties.Offset) - _store.Settings.TextIndent);
MS\Internal\TextFormatting\LexicalChunk.cs (2)
85return ich - cchLast + Math.Min(cchLast, lsdcp - lsdcpLast); 93return ich - cchLast + Math.Min(cchLast, lsdcp - lsdcpLast);
MS\Internal\TextFormatting\LineServicesCallbacks.cs (14)
437lstTextMetrics.dvAscent = (int)Math.Round(typeface.Baseline(store.Pap.EmSize, Constants.DefaultIdealToReal, store.Settings.TextSource.PixelsPerDip, fullText.TextFormattingMode)); 438lstTextMetrics.dvMultiLineHeight = (int)Math.Round(typeface.LineSpacing(store.Pap.EmSize, Constants.DefaultIdealToReal, store.Settings.TextSource.PixelsPerDip, fullText.TextFormattingMode)); 696ulInfo.dvpFirstUnderlineOffset = (int)Math.Round(lsrun.EmSize * -underlinePositionInEm); 697ulInfo.dvpFirstUnderlineSize = (int)Math.Round(lsrun.EmSize * underlineThicknessInEm); 750stInfo.dvpLowerStrikethroughOffset = (int)Math.Round(lsrun.EmSize * strikeThroughPositionInEm); 751stInfo.dvpLowerStrikethroughSize = (int)Math.Round(lsrun.EmSize * strikeThroughThicknessInEm); 945int baselineTop = ptOrigin.y + (int)Math.Round(lsrun.EmSize * strikeThroughPositionInEm); 946int overlineTop = baselineTop - (lsrun.BaselineOffset - (int)Math.Round(lsrun.EmSize * strikeThroughThicknessInEm)); 1252penThickness = Math.Abs(penThickness); 1328drawingPenThickness = drawingPenThickness / Math.Abs(unitValue); 1997int expandedBy = Math.Max(0, interWordAdjustTo - adjustedCharWidth); 2004pplsAdjustRight[0][i] = Math.Max(0, adjustedCharWidth - interWordAdjustTo); 2130pplsCompressionRight[0][igi + i] = Math.Max(0, glyphAdvance - interWordCompressTo); 2263int expandedBy = Math.Max(0, interWordExpandTo - glyphAdvance);
MS\Internal\TextFormatting\LineServicesRun.cs (2)
58(shapeable != null ? (int)Math.Round(shapeable.Baseline * realToIdeal) : 0), 59(shapeable != null ? (int)Math.Round(shapeable.Height * realToIdeal) : 0),
MS\Internal\TextFormatting\SimpleTextLine.cs (10)
289realHeight = Math.Max(realHeight, run.Height); 290realAscent = Math.Max(realAscent, run.Baseline); 291realDescent = Math.Max(realDescent, run.Height - run.Baseline); 326_height = formatter.IdealToReal((int)Math.Round(pap.DefaultTypeface.LineSpacing(pap.EmSize, Constants.DefaultIdealToReal, PixelsPerDip, _settings.TextFormattingMode)), PixelsPerDip); 327_baselineOffset = formatter.IdealToReal((int)Math.Round(pap.DefaultTypeface.Baseline(pap.EmSize, Constants.DefaultIdealToReal, PixelsPerDip, _settings.TextFormattingMode)), PixelsPerDip); 361_idealOffsetUnRounded = (int)Math.Round((paragraphWidth - idealWidthAtTrailing) * 0.5); 844int first = Math.Max(ich, dcp) + _cpFirst; 845int afterLast = Math.Min(ich + run.Length, dcp + textLength) + _cpFirst; 1212cpVisible = Math.Max(cpRunStart, cp); 1244cpVisible = Math.Min(cpRunEnd, cp);
MS\Internal\TextFormatting\TextFormatterImp.cs (6)
649return Math.Round(value * pixelsPerDip, midpointRounding) / pixelsPerDip; 692value = Math.Max(value, Constants.DefaultIdealToReal); 703int value = (int)Math.Round(i * ToIdeal); 707value = Math.Max(value, 1); 724int value = (int)Math.Floor(i * ToIdeal); 728value = Math.Max(value, 1);
MS\Internal\TextFormatting\TextMarkerSource.cs (1)
178Math.Min(_characterArray.Length, textSourceCharacterIndexLimit)
MS\Internal\TextFormatting\TextMetrics.cs (5)
170int lscpFirstIndependence = Math.Max( 190_baselineOffset = (int)Math.Round( 201_textAscent = (int)Math.Round(pap.DefaultTypeface.Baseline(pap.EmSize, Constants.DefaultIdealToReal, _pixelsPerDip, fullText.TextFormattingMode)); 202_textHeight = (int)Math.Round(pap.DefaultTypeface.LineSpacing(pap.EmSize, Constants.DefaultIdealToReal, _pixelsPerDip, fullText.TextFormattingMode)); 253_paragraphToText = (int)Math.Round((paragraphWidth + _textStart - _textWidthAtTrailing) * 0.5);
MS\Internal\TextFormatting\TextProperties.cs (1)
388return (int)Math.Round(properties.FontRenderingEmSize * 0.75 * _textRunLength * realToIdeal);
MS\Internal\TextFormatting\TextRunCacheImp.cs (3)
192looseCharLength = (int)Math.Round(TextStore.TypicalCharactersPerLine * 0.25); 215int lookAheadLimit = Math.Min(runLength, looseCharLength + TextStore.TypicalCharactersPerLine); 241looseCharLength = Math.Min(runLength, endOffset);
MS\Internal\TextFormatting\TextShapeableCharacters.cs (2)
350advanceWidthsUnshaped[i] = (int)Math.Round(TextFormatterImp.RoundDipForDisplayMode(glyphMetrics[i].AdvanceWidth * designToEm, pixelsPerDip) * scalingFactor); 362advanceWidthsUnshaped[i] = (int)Math.Round(glyphMetrics[i].AdvanceWidth * designToEm);
MS\Internal\TextFormatting\TextStore.cs (16)
509int effectedRangeStart = Math.Max(cpFetched - offset, bounds[0].Position); 510int effectedRangeEnd = Math.Min(cpFetched - offset + runInfo.Length, bounds[bounds.Length - 1].Position); 520int currentRangeEnd = Math.Min(bounds[i].Position, effectedRangeEnd); 554currentPosition = Math.Max(currentPosition, bounds[i + 1].Position); 1122int runLength = Math.Min(span.length, cchToAdd - ichRun); 1210int first = limit - Math.Min(charRange.Length, limitCp - firstCp); 1293int spanLength = Math.Min(runInfoSpanRider.Length, textEffectsSpanRider.Length); 1294int ichEnd = Math.Min(ichRun + spanLength, cchUniform); 1564(int)Math.Round(realToIdeal * runInfo.TextRun.Properties.FontRenderingEmSize), 1719(int)Math.Round(realToIdeal * runInfo.TextRun.Properties.FontRenderingEmSize), 1958textTop = Math.Max(textTop, lsrun.BaselineOffset); 1959textBottom = Math.Max(textBottom, lsrun.Descent); 1979textBottom = Math.Max(textBottom, lsrun.Height + top); 1983textBottom = Math.Max(textBottom, lsrun.Height + textTop); 2047cellAscent = Math.Max(cellAscent, lsrun.BaselineOffset - move); 2048cellDescent = Math.Max(cellDescent, lsrun.Descent + move);
MS\Internal\TextFormatting\ThousandthOfEmRealDoubles.cs (1)
272thousandthOfEm = (short) Math.Round(scaled);
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\FloatUtil.cs (6)
36float eps = ((float)Math.Abs(a) + (float)Math.Abs(b) + 10.0f) * FLT_EPSILON; 46return (float)Math.Abs(a-1.0f) < 10.0f * FLT_EPSILON; 54return (float)Math.Abs(a) < 10.0f * FLT_EPSILON; 63return Math.Abs(denominator) <= Math.Abs(numerator) * INVERSE_FLT_MAX_PRECISION;
src\Microsoft.DotNet.Wpf\src\Shared\MS\Internal\Ink\BitStream.cs (1)
280int rightShiftNextByteBy = Math.Abs((countOfBits - _cbitsInPartialByte) - Native.BitsPerByte);
System\Windows\dataobject.cs (1)
2345_current = _current + (int)Math.Min(celt, Int32.MaxValue - _current);
System\Windows\Ink\IncrementalHitTester.cs (4)
828weight += Math.Sqrt(da.Width*da.Width + da.Height*da.Height) / 2.0f; 833weight += Math.Sqrt(spine.LengthSquared) / 2.0f; 838weight += Math.Sqrt(da.Width*da.Width + da.Height*da.Height) / 2.0f; 843weight += Math.Sqrt(spine.LengthSquared) / 2.0f;
System\Windows\Ink\Stroke.cs (8)
231double min = Math.Min(shapeBoundingBox.Width, shapeBoundingBox.Height); 232tolerance = Math.Log10(min + min); 355return Math.Sqrt(spine.LengthSquared); 748Math.Ceiling(cutAt[cutAt.Length - 1].EndFIndex) > sourceStylusPoints.Count - 1)); 804Math.Ceiling(cutAt[cutAt.Length - 1].EndFIndex) > sourceStylusPoints.Count - 1)); 856? 0 : (int)Math.Floor(beginFIndex); 860? (sourceStylusPoints.Count - 1) : (int)Math.Ceiling(endFIndex); 914double ceiling = Math.Ceiling(endFIndex);
System\Windows\Ink\Stroke2.cs (4)
384selectedDA.Height = Math.Max(selectedDA.Height, DrawingAttributes.DefaultHeight); 385selectedDA.Width = Math.Max(selectedDA.Width, DrawingAttributes.DefaultWidth); 683double newWidth = Math.Sqrt(w.X * w.X + w.Y * w.Y); 684double newHeight = Math.Sqrt(h.X * h.X + h.Y * h.Y);
System\Windows\Input\AngleUtil.cs (2)
14return degrees * Math.PI / 180.0; 22return radians * 180.0 / Math.PI;
System\Windows\Input\ManipulationLogic.cs (1)
499Radius = (float)Math.Max(1.0, pivot.Radius)
System\Windows\Input\MouseDevice.cs (2)
2139return (Math.Abs(newPosition.X - _lastClick.X) < doubleClickDeltaX) && 2140(Math.Abs(newPosition.Y - _lastClick.Y) < doubleClickDeltaY);
System\Windows\Input\Stylus\Common\StylusPointCollection.cs (4)
525output[x] = (int)Math.Round(stylusPoint.X * StrokeCollectionSerializer.AvalonToHimetricMultiplier); 526output[x + 1] = (int)Math.Round(stylusPoint.Y * StrokeCollectionSerializer.AvalonToHimetricMultiplier); 594output[0][b] = (int)Math.Round(stylusPoint.X * StrokeCollectionSerializer.AvalonToHimetricMultiplier); 595output[1][b] = (int)Math.Round(stylusPoint.Y * StrokeCollectionSerializer.AvalonToHimetricMultiplier);
System\Windows\Input\Stylus\Pointer\PointerFlickEngine.cs (5)
432_flickDirectionRadians = Math.Atan2(newData.PhysicalPoint.Y - _flickStartPhysical.Y, newData.PhysicalPoint.X - _flickStartPhysical.X); 464return ((180 * radians / Math.PI) + 360) % 360; 475return Math.Sqrt(Math.Pow((p1.X - p2.X), 2) + Math.Pow((p1.Y - p2.Y), 2));
System\Windows\Input\Stylus\Pointer\PointerLogic.cs (7)
477return new Point(Math.Round(pt.X), Math.Round(pt.Y)); 493return new Point(Math.Round(pt.X), Math.Round(pt.Y)); 1275int elapsedTime = Math.Abs(unchecked(stylusDownEventArgs.Timestamp - _lastTapTimeTicks)); 1281bool isSameSpot = (Math.Abs(ptPixels.X - _lastTapPoint.X) < doubleTapSize.Width) && 1282(Math.Abs(ptPixels.Y - _lastTapPoint.Y) < doubleTapSize.Height);
System\Windows\Input\Stylus\Pointer\PointerStylusPlugInManager.cs (2)
164ptTablet.X = (int)Math.Round(ptTablet.X); // Make sure we snap to whole window pixels. 165ptTablet.Y = (int)Math.Round(ptTablet.Y);
System\Windows\Input\Stylus\Pointer\PointerStylusPointPropertyInfoHelper.cs (1)
84float exponent = (float)Math.Pow(10, mappedExponent);
System\Windows\Input\Stylus\Pointer\PointerTabletDevice.cs (6)
123Size mouseDoubleTapDefault = new Size(Math.Max(1, MS.Win32.SafeSystemMetrics.DoubleClickDeltaX / 2), 124Math.Max(1, MS.Win32.SafeSystemMetrics.DoubleClickDeltaY / 2)); 134_doubleTapSize = new Size((int)Math.Round((ScreenSize.Width * DoubleTapDelta) / dwXValue), 135(int)Math.Round((ScreenSize.Height *DoubleTapDelta) / dwYValue)); 139_doubleTapSize.Width = Math.Max(mouseDoubleTapDefault.Width, _doubleTapSize.Width); 140_doubleTapSize.Height = Math.Max(mouseDoubleTapDefault.Height, _doubleTapSize.Height);
System\Windows\Input\Stylus\Wisp\PenContexts.cs (3)
187if (context.QueuedInRangeCount > 0 || (Math.Abs(unchecked(timestamp - context.LastInRangeTime)) <= 500)) 490ptTablet.X = (int)Math.Round(ptTablet.X); // Make sure we snap to whole window pixels. 491ptTablet.Y = (int)Math.Round(ptTablet.Y);
System\Windows\Input\Stylus\Wisp\WispLogic.cs (6)
1081int timeSpan = Math.Abs(unchecked(stylusDownEventArgs.Timestamp - stylusDevice.LastTapTime)); 1085bool isSameSpot = (Math.Abs(pPixelPoint.X - pLastPixelPoint.X) < doubleTapSize.Width) && 1086(Math.Abs(pPixelPoint.Y - pLastPixelPoint.Y) < doubleTapSize.Height); 3242if (Math.Abs(unchecked(timestamp - _lastInRangeTime)) <= 500) 3587pt.X = (int)Math.Round(pt.X); // Make sure we return whole numbers (pixels are whole numbers) 3588pt.Y = (int)Math.Round(pt.Y);
System\Windows\Input\Stylus\Wisp\WispStylusDevice.cs (2)
1470if ((Math.Abs(_lastMouseScreenLocation.X - dragPosition.X) > delta.Width) || 1471(Math.Abs(_lastMouseScreenLocation.Y - dragPosition.Y) > delta.Height))
System\Windows\Input\Stylus\Wisp\WispTabletDevice.cs (12)
272Size mouseDragDefault = new Size(Math.Max(1, SafeSystemMetrics.DragDeltaX / 2), 273Math.Max(1, SafeSystemMetrics.DragDeltaY / 2)); 274Size mouseDoubleTapDefault = new Size(Math.Max(1, SafeSystemMetrics.DoubleClickDeltaX / 2), 275Math.Max(1, SafeSystemMetrics.DoubleClickDeltaY / 2)); 285_cancelSize = new Size((int)Math.Round((ScreenSize.Width * stylusLogic.CancelDelta) / dwXValue), 286(int)Math.Round((ScreenSize.Height * stylusLogic.CancelDelta) / dwYValue)); 290_cancelSize.Width = Math.Max(mouseDragDefault.Width, _cancelSize.Width); 291_cancelSize.Height = Math.Max(mouseDragDefault.Height, _cancelSize.Height); 293_doubleTapSize = new Size((int)Math.Round((ScreenSize.Width * stylusLogic.DoubleTapDelta) / dwXValue), 294(int)Math.Round((ScreenSize.Height * stylusLogic.DoubleTapDelta) / dwYValue)); 298_doubleTapSize.Width = Math.Max(mouseDoubleTapDefault.Width, _doubleTapSize.Width); 299_doubleTapSize.Height = Math.Max(mouseDoubleTapDefault.Height, _doubleTapSize.Height);
System\Windows\InterOp\HwndPointerInputProvider.cs (2)
327originOffsetX = (int)Math.Round(originTabletCoord.X); 328originOffsetY = (int)Math.Round(originTabletCoord.Y);
System\Windows\InterOp\HwndSource.cs (2)
905size = new Point(Math.Ceiling(size.X), Math.Ceiling(size.Y));
System\Windows\InterOp\HwndTarget.cs (4)
779(float)(Math.Ceiling((double)(_hwndClientRectInScreenCoords.right - _hwndClientRectInScreenCoords.left))), 780(float)(Math.Ceiling((double)(_hwndClientRectInScreenCoords.bottom - _hwndClientRectInScreenCoords.top)))); 1590(float)(Math.Ceiling((double)(_hwndClientRectInScreenCoords.right - _hwndClientRectInScreenCoords.left))), 1591(float)(Math.Ceiling((double)(_hwndClientRectInScreenCoords.bottom - _hwndClientRectInScreenCoords.top))));
System\Windows\Markup\XmlLanguage.cs (1)
423specificity = Math.Max(GetSubtagCount(languageTag), 1 + GetSpecificity(culture.Parent, maxDepth - 1));
System\Windows\Media\Animation\BackEase.cs (4)
44double amp = Math.Max(0.0, Amplitude); 45return Math.Pow(normalizedTime, 3.0) - normalizedTime * amp * Math.Sin(Math.PI * normalizedTime);
System\Windows\Media\Animation\BounceEase.cs (7)
82double bounces = Math.Max(0.0, (double)Bounces); 92double pow = Math.Pow(bounciness, bounces); 105double bounceAtT = Math.Log(-unitAtT * (1.0-bounciness) + 1.0, bounciness); 106double start = Math.Floor(bounceAtT); 111double startTime = (1.0 - Math.Pow(bounciness, start)) / (oneMinusBounciness * sumOfUnits); 112double endTime = (1.0 - Math.Pow(bounciness, end)) / (oneMinusBounciness * sumOfUnits); 118double amplitude = Math.Pow(1.0 / bounciness, (bounces - start));
System\Windows\Media\Animation\CircleEase.cs (3)
16normalizedTime = Math.Max(0.0, Math.Min(1.0, normalizedTime)); 17return 1.0 - Math.Sqrt(1.0 - normalizedTime * normalizedTime);
System\Windows\Media\Animation\Clock.cs (3)
2147timeUntilNextBoundary = DivideTimeSpan(_currentDuration.TimeSpan, Math.Abs(parentSpeed)); 4170long error = (long)Math.Max(_appliedSpeedRatio, 1.0); 4179Debug.Assert(Math.Abs(optimizedInputTime - inputTime) <= error,
System\Windows\Media\Animation\ClockGroup.cs (1)
200desiredFrameRate = Math.Max(desiredFrameRate, currentDesiredFrameRate.Value);
System\Windows\Media\Animation\DoubleAnimationUsingPath.cs (2)
295double angle = Math.Acos(x) * (180.0 / Math.PI);
System\Windows\Media\Animation\ElasticEase.cs (7)
72double oscillations = Math.Max(0.0, (double)Oscillations); 73double springiness = Math.Max(0.0, Springiness); 81expo = (Math.Exp(springiness * normalizedTime) - 1.0) / (Math.Exp(springiness) - 1.0); 84return expo * (Math.Sin((Math.PI * 2.0 * oscillations + Math.PI * 0.5) * normalizedTime));
System\Windows\Media\Animation\ExponentialEase.cs (2)
54return (Math.Exp(factor * normalizedTime) - 1.0) / (Math.Exp(factor) - 1.0);
System\Windows\Media\Animation\KeySpline.cs (2)
354absdx = Math.Abs(dx); 369if (Math.Abs(x - time) < accuracy * absdx)
System\Windows\Media\Animation\PowerEase.cs (2)
47double power = Math.Max(0.0, Power); 48return Math.Pow(normalizedTime, power);
System\Windows\Media\Animation\SineEase.cs (2)
16return 1.0 - Math.Sin(Math.PI * 0.5 * (1 - normalizedTime));
System\Windows\Media\ArcSegment.cs (1)
88count = Math.Min(count, 4);
System\Windows\Media\ByteStreamGeometryContext.cs (2)
477int cbDataForThisChunk = Math.Min(cbDataSize, 513int newChunkSize = Math.Min(2*_chunkList[_chunkList.Count-1].Length, c_maxChunkSize);
System\Windows\Media\Color.cs (2)
1047return (float)Math.Pow(((double)val + 0.055) / 1.055, 2.4); 1071return ((byte)((255.0f * ((1.055f * (float)Math.Pow((double)val, (1.0 / 2.4))) - 0.055f)) + 0.5f));
System\Windows\Media\Effects\DropShadowEffect.cs (3)
40double direction = Math.PI/180 * Direction; 41double offsetX = depth * Math.Cos(direction); 42double offsetY = depth * Math.Sin(direction);
System\Windows\Media\EllipseGeometry.cs (14)
86currentCenter.X - Math.Abs(currentRadiusX), 87currentCenter.Y - Math.Abs(currentRadiusY), 882.0 * Math.Abs(currentRadiusX), 892.0 * Math.Abs(currentRadiusY)); 152strokeThickness = Math.Abs(pen.Thickness); 156center.X - Math.Abs(radiusX)-0.5*strokeThickness, 157center.Y - Math.Abs(radiusY)-0.5*strokeThickness, 1582.0 * Math.Abs(radiusX)+strokeThickness, 1592.0 * Math.Abs(radiusY)+strokeThickness); 237double area = Math.Abs(RadiusX * RadiusY) * Math.PI; 243area *= Math.Abs(transform.Value.Determinant); 347radiusX = Math.Abs(radiusX); 348radiusY = Math.Abs(radiusY);
System\Windows\Media\FamilyTypeface.cs (1)
300pAdvances[i] = Math.Max(0, (int)((metrics.BlackBoxWidth + metrics.LeftSideBearing + metrics.RightSideBearing) * emSize));
System\Windows\Media\FormattedText.cs (21)
328i = Math.Min(limit, i + formatRider.Length); 402i = Math.Min(limit, i + formatRider.Length); 457i = Math.Min(limit, i + formatRider.Length); 510i = Math.Min(limit, i + formatRider.Length); 569i = Math.Min(limit, i + formatRider.Length); 628i = Math.Min(limit, i + formatRider.Length); 680i = Math.Min(limit, i + formatRider.Length); 733i = Math.Min(limit, i + formatRider.Length); 786i = Math.Min(limit, i + formatRider.Length); 838i = Math.Min(limit, i + formatRider.Length); 979return _that._maxTextWidths[Math.Min(line, _that._maxTextWidths.Length - 1)]; 1123Math.Min(textSourcePosition + line.Length - 1, _that._text.Length - 1) 1634int x0 = Math.Max(enumerator.Position, startIndex); 1635int x1 = Math.Min(enumerator.Position + enumerator.Length, startIndex + count); 1786accBlackBoxLeft = Math.Min(accBlackBoxLeft, blackBoxLeft); 1787accBlackBoxRight = Math.Max(accBlackBoxRight, blackBoxRight); 1788accBlackBoxBottom = Math.Max(accBlackBoxBottom, blackBoxBottom); 1789accBlackBoxTop = Math.Min(accBlackBoxTop, blackBoxTop); 1795metrics.Width = Math.Max(metrics.Width, currentLine.Width); 1796metrics.WidthIncludingTrailingWhitespace = Math.Max(metrics.WidthIncludingTrailingWhitespace, currentLine.WidthIncludingTrailingWhitespace); 1797lineStartOfLongestLine = Math.Min(lineStartOfLongestLine, currentLine.Start);
System\Windows\Media\GlyphRun.cs (4)
1405double inflation = Math.Min(_renderingEmSize / 7.0, 1.0); 1447return Math.Max(advance, oneSideBearing + otherSideBearing + 1); 1754_baseVectorX = Math.Sqrt(m11 * m11 + m12 * m12); 1760_baseVectorY = _baseVectorX == 0 ? 0 : Math.Abs(m11 * m22 - m12 * m21) / _baseVectorX;
System\Windows\Media\GlyphsSerializer.cs (6)
53Math.Max( 179int roundedShapingAdvance = (int)Math.Round(_idealAdvanceTotal + shapingAdvance - _currentAdvanceTotal); 180int roundedFontAdvance = (int)Math.Round(fontAdvance); 201int offset = (int)Math.Round(_offsets[glyph].X * _milToEm); 209offset = (int)Math.Round(_offsets[glyph].Y * _milToEm); 275lastCaretStop = Math.Min(i | 3, _caretStops.Count - 1);
System\Windows\Media\GlyphTypeface.cs (3)
1344advanceWidthsUnshaped[i] = (int)Math.Round(TextFormatterImp.RoundDipForDisplayMode(glyphMetrics[i].AdvanceWidth * designToEm, pixelsPerDip) * scalingFactor); 1352advanceWidthsUnshaped[i] = (int)Math.Round(glyphMetrics[i].AdvanceWidth * designToEm); 1360int missingGlyphWidth = (int)Math.Round(TextFormatterImp.RoundDip(emSize * GetAdvanceWidth(0, pixelsPerDip, textFormattingMode, isSideways), pixelsPerDip, textFormattingMode) * scalingFactor);
System\Windows\Media\Imaging\BitmapDownload.cs (1)
343int percentComplete = (int)Math.Floor(100.0 * (double)entry.outputStream.Length / (double)entry.contentLength);
System\Windows\Media\Imaging\BitmapPalette.cs (1)
268int numColors = Math.Min(256, _colors.Count);
System\Windows\Media\Imaging\BitmapSource.cs (2)
463return new Size(Math.Max(0, GetWidthInternal()), 464Math.Max(0, GetHeightInternal()));
System\Windows\Media\Imaging\TransformedBitmap.cs (6)
117scaleX = Math.Abs(m.M11); 118scaleY = Math.Abs(m.M22); 136scaleX = Math.Abs(m.M12); 137scaleY = Math.Abs(m.M21); 176uint width = Math.Max(1, (uint)(scaleX * _source.PixelWidth + 0.5)); 177uint height = Math.Max(1, (uint)(scaleY * _source.PixelHeight + 0.5));
System\Windows\Media\LinearGradientBrush.cs (3)
211angle = angle * (1.0/180.0) * System.Math.PI; 213return (new Point(System.Math.Cos(angle), System.Math.Sin(angle)));
System\Windows\Media\MatrixStack.cs (4)
82_highWaterMark = Math.Max(_highWaterMark, _size); 120_highWaterMark = Math.Max(_highWaterMark, _size); 150_highWaterMark = Math.Max(_highWaterMark, _size); 193int newSize = Math.Max(_highWaterMark, s_initialSize);
System\Windows\Media\MediaContext.cs (4)
98int sqrt = (int) Math.Sqrt(number); 570nextTickNeeded = TimeSpan.FromTicks(Math.Max(nextTickNeeded.Ticks, minimumDelay.Ticks)); 749_animationRenderRate = Math.Max(_adjustedRefreshRate, _timeManager.GetMaxDesiredFrameRate()); 801_animationRenderRate = Math.Min(_animationRenderRate, 1000);
System\Windows\Media\ParsersCommon.cs (2)
365_curIndex = Math.Min(_curIndex+8, _pathLength); // "Infinity" has 8 characters 375_curIndex = Math.Min(_curIndex+3, _pathLength); // "NaN" has 3 characters
System\Windows\Media\RectangleGeometry.cs (9)
190strokeThickness = Math.Abs(pen.Thickness); 284double area = Math.Abs(rect.Width * rect.Height); 287area -= Math.Abs(radiusX * radiusY) * (4.0 - Math.PI); 293area *= Math.Abs(transform.Value.Determinant); 463radiusX = Math.Min(rect.Width * (1.0 / 2.0), Math.Abs(radiusX)); 464radiusY = Math.Min(rect.Height * (1.0 / 2.0), Math.Abs(radiusY));
System\Windows\Media\RenderData.cs (1)
474int newSize = Math.Max((_buffer.Length << 1) - (_buffer.Length >> 1), cbRequiredSize);
System\Windows\Media\textformatting\CharacterBufferReference.cs (1)
87int maxOffset = (charBuffer == null) ? 0 : Math.Max(0, charBuffer.Count - 1);
System\Windows\Media\Typeface.cs (2)
643nominalWidths[i] = (int)Math.Round(TextFormatterImp.RoundDipForDisplayMode(glyphMetrics[i].AdvanceWidth * designToEm, pixelsPerDip) * toIdeal); 652nominalWidths[i] = (int)Math.Round(glyphMetrics[i].AdvanceWidth * designToEm);
System\Windows\Media\VisualCollection.cs (1)
232InternalCapacity = Math.Max(min, (int)(InternalCapacity * c_growFactor));
System\Windows\Media\VisualProxy.cs (1)
572Array.Copy(_tail, reallocatedTail, Math.Min(_tail.Length, newLength));
System\Windows\Media3D\AxisAngleRotation3D.cs (4)
121Math.E, Math.PI, Math.E * Math.PI, 55.0
System\Windows\Media3D\OrthographicCamera.cs (1)
224return x + 0.1*Math.Abs(x) + 1.0;
System\Windows\Media3D\PerspectiveCamera.cs (2)
78double halfWidthDepthRatio = Math.Tan(fov/2); 126double halfWidthDepthRatio = Math.Tan(fov/2);
System\Windows\Media3D\Quaternion.cs (34)
70double angleInRadians = angleInDegrees * (Math.PI / 180.0); 74Vector3D v = (axisOfRotation / length) * Math.Sin(0.5 * angleInRadians); 78_w = Math.Cos(0.5 * angleInRadians); 142double msin = Math.Sqrt(_x*_x + _y*_y + _z*_z); 151double maxcoeff = Math.Max(Math.Abs(_x),Math.Max(Math.Abs(_y),Math.Abs(_z))); 155msin = Math.Sqrt(x*x + y*y + z*z); 161return Math.Atan2(msin,mcos) * (360.0 / Math.PI); 241double rmax = 1.0/Max(Math.Abs(_x), 242Math.Abs(_y), 243Math.Abs(_z), 244Math.Abs(_w)); 252double normInverse = 1.0 / Math.Sqrt(norm2); 426double max = Math.Max(Math.Max(Math.Abs(_x),Math.Abs(_y)), 427Math.Max(Math.Abs(_z),Math.Abs(_w))); 434double smallLength = Math.Sqrt(x*x+y*y+z*z+w*w); 438return Math.Sqrt(norm2); 542double theta = t * Math.PI; 544scaleFrom = Math.Cos(theta); 545scaleTo = Math.Sin(theta); 550double omega = Math.Acos(cosOmega); 551double sinOmega = Math.Sqrt(1.0 - cosOmega*cosOmega); 552scaleFrom = Math.Sin((1.0 - t) * omega) / sinOmega; 553scaleTo = Math.Sin(t * omega) / sinOmega; 561double lengthOut = lengthFrom * Math.Pow(lengthTo/lengthFrom, t);
System\Windows\Media3D\Ray3DHitTestResult.cs (1)
94return Math.Sign(x.DistanceToRayOrigin - y.DistanceToRayOrigin);
System\Windows\Media3D\Rect3D.cs (18)
77_x = Math.Min(point1._x, point2._x); 78_y = Math.Min(point1._y, point2._y); 79_z = Math.Min(point1._z, point2._z); 80_sizeX = Math.Max(point1._x, point2._x) - _x; 81_sizeY = Math.Max(point1._y, point2._y) - _y; 82_sizeZ = Math.Max(point1._z, point2._z) - _z; 418double x = Math.Max(_x, rect._x); 419double y = Math.Max(_y, rect._y); 420double z = Math.Max(_z, rect._z); 421_sizeX = Math.Min(_x + _sizeX, rect._x + rect._sizeX) - x; 422_sizeY = Math.Min(_y + _sizeY, rect._y + rect._sizeY) - y; 423_sizeZ = Math.Min(_z + _sizeZ, rect._z + rect._sizeZ) - z; 456double x = Math.Min(_x, rect._x); 457double y = Math.Min(_y, rect._y); 458double z = Math.Min(_z, rect._z); 459_sizeX = Math.Max(_x + _sizeX, rect._x + rect._sizeX) - x; 460_sizeY = Math.Max(_y + _sizeY, rect._y + rect._sizeY) - y; 461_sizeZ = Math.Max(_z + _sizeZ, rect._z + rect._sizeZ) - z;
System\Windows\Media3D\Vector3D.cs (11)
61return Math.Sqrt(_x * _x + _y * _y + _z * _z); 86double m = Math.Abs(_x); 87double absy = Math.Abs(_y); 88double absz = Math.Abs(_z); 102double length = Math.Sqrt(_x * _x + _y * _y + _z * _z); 168theta = Math.PI - 2.0 * Math.Asin((-vector1 - vector2).Length / 2.0); 172theta = 2.0 * Math.Asin((vector1 - vector2).Length / 2.0); 464return new Size3D(Math.Abs(vector._x), Math.Abs(vector._y), Math.Abs(vector._z));
System\Windows\UIElement.cs (2)
1091newValue = Math.Round(value * dpiScale) / dpiScale; 1102newValue = Math.Round(value);
PresentationFramework (1131)
Microsoft\Win32\CommonDialog.cs (2)
323(int)Math.Round(x), 324(int)Math.Round(y), // new X and Y positions
MS\Internal\AnimatedTypeHelpers.cs (6)
81return Math.Abs(to - from); 87Math.Pow(GetSegmentLengthDouble(from.Left, to.Left), 2.0) 88+ Math.Pow(GetSegmentLengthDouble(from.Top, to.Top), 2.0) 89+ Math.Pow(GetSegmentLengthDouble(from.Right, to.Right), 2.0) 90+ Math.Pow(GetSegmentLengthDouble(from.Bottom, to.Bottom), 2.0); 92return Math.Sqrt(totalLength);
MS\Internal\Annotations\Component\MarkedHighlightComponent.cs (1)
848sign = Math.Sign(next.Left - current.Left);
MS\Internal\AppModel\IconHelper.cs (1)
338return (((int)Math.Ceiling(original) + (nBitsCount - 1)) / nBitsCount) * nBitsCount;
MS\Internal\Controls\InkCanvasInnerCanvas.cs (4)
94newSize.Width = Math.Max(newSize.Width, left + child.DesiredSize.Width); 98newSize.Width = Math.Max(newSize.Width, child.DesiredSize.Width); 104newSize.Height = Math.Max(newSize.Height, top + child.DesiredSize.Height); 108newSize.Height = Math.Max(newSize.Height, child.DesiredSize.Height);
MS\Internal\Controls\StickyNote\StickyNoteAnnotations.cs (6)
1047if (DoubleUtil.GreaterThan(Math.Abs(offsetX), Math.Abs(_offsetX))) 1053offset = Math.Max(offset, -(rectStickyNote.Left - rectPage.Left)); 1059if (DoubleUtil.GreaterThan(Math.Abs(offsetY), Math.Abs(_offsetY))) 1064offset = Math.Max(offset, -(rectStickyNote.Top - rectPage.Top));
MS\Internal\Data\RBTree.cs (1)
391int n = Math.Min(mid - left, right - mid);
MS\Internal\Documents\ContentElementCollection.cs (1)
666PrivateCapacity = Math.Max(min, PrivateCapacity * 2);
MS\Internal\Documents\DocumentGrid.cs (18)
316if (Math.Abs(pageNumber - _firstVisiblePageNumber) > 1) 577double clippedHorizontalOffset = Math.Min(_horizontalOffset, ExtentWidth - ViewportWidth); 578clippedHorizontalOffset = Math.Max(clippedHorizontalOffset, 0.0); 620double clippedVerticalOffset = Math.Min(_verticalOffset, ExtentHeight - ViewportHeight); 621clippedVerticalOffset = Math.Max(clippedVerticalOffset, 0.0); 1217pageOffset = new Point(Math.Max(ViewportWidth, ExtentWidth) - (xOffset + pageSize.Width), yOffset); 1445visiblePages.Add(_childrenCollection[_firstPageVisualIndex + j - Math.Max(0, firstPage)]); 1599double centerWidth = Math.Max(ViewportWidth, ExtentWidth); 2222(int)Math.Floor(ViewportWidth / 2227maxColumns = Math.Min(maxColumns, _pageCache.PageCount); 2228maxColumns = Math.Min(maxColumns, DocumentViewerConstants.MaximumMaxPagesAcross); 2239int rows = (int)Math.Floor((double)(_pageCache.PageCount / columns)); 2251double aspectDiff = Math.Abs(layoutAspect - viewportAspect); 2363newScale = Math.Max(newScale, CurrentMinimumScale); 2364newScale = Math.Min(newScale, DocumentViewerConstants.MaximumScale); 2433scaleFactor = Math.Min(compensatedViewportWidth / rowWidth, compensatedViewportHeight / rowHeight); 2462scaleFactor = Math.Min(compensatedViewportWidth / rowWidth, 2692Math.Max(0.0, (ExtentWidth - row.RowSize.Width) / 2.0) : 0.0;
MS\Internal\Documents\DocumentPageTextView.cs (2)
653while (Math.Abs(pagesMoved) < Math.Abs(count))
MS\Internal\Documents\FlowDocumentView.cs (8)
82desiredSize.Width = Math.Min(constraint.Width, _formatter.DocumentPage.Size.Width); 83desiredSize.Height = Math.Min(constraint.Height, _formatter.DocumentPage.Size.Height); 132if (Math.Abs(_scrollData.ExtentWidth - _scrollData.ViewportWidth) < 1) 136if (Math.Abs(_scrollData.ExtentHeight - _scrollData.ViewportHeight) < 1) 142Math.Max(0, Math.Min(_scrollData.ExtentWidth - _scrollData.ViewportWidth, _scrollData.HorizontalOffset)), 143Math.Max(0, Math.Min(_scrollData.ExtentHeight - _scrollData.ViewportHeight, _scrollData.VerticalOffset)));
MS\Internal\Documents\IFlowDocumentViewer.cs (2)
831GoToPage(Math.Max(1, MasterPageNumber - 2)); 839GoToPage(Math.Min(PageCount, MasterPageNumber + 2));
MS\Internal\Documents\MultiPageTextView.cs (17)
760Invariant.Assert(Math.Abs(request.NewCount) >= Math.Abs(linesMoved)); 832Invariant.Assert(Math.Abs(request.NewCount) >= Math.Abs(pagesMoved)); 980Invariant.Assert(Math.Abs(pagesMoved) <= Math.Abs(count)); 1098horz = Math.Min(Math.Abs(point.X - textViewBounds.Left), Math.Abs(point.X - textViewBounds.Right)); 1106vert = Math.Min(Math.Abs(point.Y - textViewBounds.Top), Math.Abs(point.Y - textViewBounds.Bottom)); 1108textViewProximities[i] = Math.Sqrt(Math.Pow(horz, 2) + Math.Pow(vert, 2)); 1193int closestDistance = Math.Abs(count); 1218int distance = Math.Abs(currentPageNumber - pageNumber);
MS\Internal\Documents\RowCache.cs (13)
311double roundedOffset = Math.Round(offset, _findOffsetPrecision); 319double rowOffset = Math.Round(_rowCache[i].VerticalOffset, _findOffsetPrecision); 320double rowHeight = Math.Round(_rowCache[i].RowSize.Height, _findOffsetPrecision); 411startOffset = Math.Round(startOffset, _findOffsetPrecision); 412endOffset = Math.Round(endOffset, _findOffsetPrecision); 418double rowOffset = Math.Round(_rowCache[i].VerticalOffset, _findOffsetPrecision); 470_extentWidth = Math.Max(currentRow.RowSize.Width, _extentWidth); 537_layoutColumns = Math.Min(_layoutColumns, PageCache.PageCount); 538_layoutColumns = Math.Max(1, _layoutColumns); 652pivotPage = Math.Max(0, PageCache.PageCount - columns); 976_extentWidth = Math.Max(newRow.RowSize.Width, _extentWidth); 1104_extentWidth = Math.Max(row.RowSize.Width, _extentWidth); 1372_rowSize.Height = Math.Max(pageSize.Height, _rowSize.Height);
MS\Internal\Documents\ScrollData.cs (4)
133offset = Math.Max(0, Math.Min(_extent.Width - _viewport.Width, offset)); 155offset = Math.Max(0, Math.Min(_extent.Height - _viewport.Height, offset));
MS\Internal\Documents\TextBoxLine.cs (1)
117int runLength = Math.Min(128, position.GetTextRunLength(LogicalDirection.Backward));
MS\Internal\Documents\TextBoxView.cs (32)
501desiredSize.Width = Math.Min(constraint.Width, desiredSize.Width); 502desiredSize.Height = Math.Min(constraint.Height, desiredSize.Height); 695int startOffset = Math.Min(_lineMetrics[_lineMetrics.Count - 1].EndOffset, startPosition.Offset); 696int endOffset = Math.Min(_lineMetrics[_lineMetrics.Count - 1].EndOffset, endPosition.Offset); 703firstLineIndex = Math.Max(firstLineIndex, GetLineIndexFromOffset(startOffset, LogicalDirection.Forward)); 704lastLineIndex = Math.Min(lastLineIndex, GetLineIndexFromOffset(endOffset, LogicalDirection.Backward)); 773int nextLineIndex = Math.Max(0, Math.Min(_lineMetrics.Count - 1, lineIndex + count)); 1789Math.Max(0, Math.Min(_scrollData.ExtentWidth - _scrollData.ViewportWidth, _scrollData.HorizontalOffset)), 1790Math.Max(0, Math.Min(_scrollData.ExtentHeight - _scrollData.ViewportHeight, _scrollData.VerticalOffset))); 1936int endOffset = Math.Min(range.StartIndex + range.PositionsAdded, _host.TextContainer.SymbolCount); 2047int startOffset = Math.Max(_lineMetrics[lineIndex].Offset, unclippedStartOffset); 2048int endOffset = Math.Min(_lineMetrics[lineIndex].EndOffset, unclippedEndOffset); 2143int startOffset = Math.Max(lineStartOffset, unclippedStartOffset); 2144int endOffset = Math.Min(lineEndOffset, unclippedEndOffset); 2203lastLineIndex = (int)Math.Ceiling((viewport.Y + viewport.Height) / _lineHeight) - 1; 2206firstLineIndex = Math.Max(0, Math.Min(firstLineIndex, _lineMetrics.Count - 1)); 2207lastLineIndex = Math.Max(0, Math.Min(lastLineIndex, _lineMetrics.Count - 1)); 2279desiredSize.Width = Math.Max(desiredSize.Width, line.Width); 2553int lastCoveredCharOffset = range.StartIndex + Math.Max(range.PositionsAdded, range.PositionsRemoved); 2649desiredSize.Width = Math.Max(desiredSize.Width, _lineMetrics[i].Width); 2712int lineIndex = Math.Max(oldLineVisualsIndex, firstLineIndex); 2713int lineCount = Math.Min(oldLastLineIndex, firstLineIndex + count - 1) - lineIndex + 1; 2807count = Math.Max(0, count); 2813count = Math.Min(count, _viewportLineVisuals.Count - start); 2991int rangeStart = Math.Max(viewportStart, selectionStart); 2992int rangeSize = Math.Min(viewportEnd, selectionEnd) - rangeStart; 3128padding = Math.Max(0, viewport.Height - _contentSize.Height);
MS\Internal\Documents\TextContainerHelper.cs (6)
199_cpFirst = Math.Min(_cpFirst, cpFirst); 200_cpLast = Math.Max(_cpLast, cpLast); 224_ranges[i * 2] = Math.Min(_ranges[i * 2], cpFirst); 225_ranges[i * 2 + 1] = Math.Max(_ranges[i * 2 + 1], cpLast); 247_ranges[pos * 2 + 1] = Math.Max(_ranges[pos * 2 + 1], _ranges[(pos + 1) * 2 + 1]); 472int depth = Math.Min(ancestorsStart.Count, ancestorsEnd.Count);
MS\Internal\Documents\TextDocumentView.cs (2)
2105double distance = Math.Abs(point.X - midPoint.X) + Math.Abs(point.Y - midPoint.Y);
MS\Internal\Documents\TextParagraphView.cs (6)
161lineIndex = Math.Max(0, lineIndex + count); 162lineIndex = Math.Min(lines.Count - 1, lineIndex); 572lineIndex = Math.Max(Math.Min((int)(point.Y / approximatedLineHeight), lines.Count - 1), 0); 718siblingGap = Math.Max(lineBox.X - (siblingLineBox.X + siblingLineBox.Width), 0); 747siblingGap = Math.Max(siblingLineBox.X - (lineBox.X + lineBox.Width), 0);
MS\Internal\Globalization\LocalizableResourceBuilder.cs (2)
572Readability readability = (Readability)Math.Min( 578Modifiability modifiability = (Modifiability)Math.Min(
MS\Internal\Helper.cs (7)
1072headerSize.Height = Math.Max(itemsCorrectionFactor.Top, headerSize.Height); 1076headerSize.Height = Math.Max(virtualizingElement.DesiredSize.Height, headerSize.Height); 1078headerSize.Width = Math.Max(virtualizingElement.DesiredSize.Width, headerSize.Width); 1109itemPixelSize.Width = Math.Max(desiredSize.Width, itemPixelSize.Width); 1122itemPixelSizeBeforeViewport.Width = Math.Max(desiredSize.Width, itemPixelSizeBeforeViewport.Width); 1134itemPixelSizeInViewport.Width = Math.Max(desiredSize.Width, itemPixelSizeInViewport.Width); 1145itemPixelSizeAfterViewport.Width = Math.Max(desiredSize.Width, itemPixelSizeAfterViewport.Width);
MS\Internal\Ink\LassoHelper.cs (6)
108double step = Math.Sqrt(MinDistanceSquared / distanceSquared); 232&& DoubleUtil.GreaterThanOrClose(point.X, Math.Min(prevLassoPoint.X, lassoPoint.X)) 233&& DoubleUtil.LessThanOrClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X))) 242if (DoubleUtil.GreaterThanOrClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X))) 248if ((0 == i) && DoubleUtil.AreClose(point.X, Math.Max(prevLassoPoint.X, lassoPoint.X))) 253else if (DoubleUtil.GreaterThanOrClose(point.X, Math.Min(prevLassoPoint.X, lassoPoint.X)))
MS\Internal\Ink\PenCursorManager.cs (3)
215int xHotspot = (int)Math.Round(hotspot.X - drawingBounds.Left); 216int yHotspot = (int)Math.Round(hotspot.Y - drawingBounds.Top); 342double maxLength = Math.Min(SystemParameters.PrimaryScreenWidth / 2, SystemParameters.PrimaryScreenHeight / 2);
MS\Internal\PtsHost\CellParagraph.cs (1)
77Math.Max(TextDpi.FromTextDpi(dvrAvailable), 0));
MS\Internal\PtsHost\ContainerParaClient.cs (2)
61_rect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du); 62_rect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv);
MS\Internal\PtsHost\ContainerParagraph.cs (13)
523fsrcToFillSubtrack.u = Math.Max(Math.Min(fsrcToFillSubtrack.u, fsrcToFill.u + fsrcToFill.du - 1), fsrcToFill.u); 524fsrcToFillSubtrack.du = Math.Max(fsrcToFillSubtrack.du, 0); 537fsrcToFillSubtrack.v = Math.Max(Math.Min(fsrcToFillSubtrack.v, fsrcToFill.v + fsrcToFill.dv - 1), fsrcToFill.v); 538fsrcToFillSubtrack.dv = Math.Max(fsrcToFillSubtrack.dv, 0); 598dvrUsed = Math.Min(fsrcToFill.dv, dvrUsed); 681urSubtrack = Math.Max(Math.Min(urTrack + mbp.MBPLeft, urTrack + durTrack - 1), urTrack); 682durSubtrack = Math.Max(durTrack - (mbp.MBPLeft + mbp.MBPRight), 0); 811urSubtrack = Math.Max(Math.Min(urTrack + mbp.MBPLeft, urTrack + durTrack - 1), urTrack); 812durSubtrack = Math.Max(durTrack - (mbp.MBPLeft + mbp.MBPRight), 0);
MS\Internal\PtsHost\DtrList.cs (2)
100int adjust = Math.Min(_dtrs[i].PositionsAdded, dtr.PositionsRemoved - delta); 114int adjust = Math.Min(dtr.PositionsRemoved, _dtrs[i].PositionsAdded - delta);
MS\Internal\PtsHost\FigureHelper.cs (5)
183value = Math.Max(1, Math.Min(value, structuralCache.CurrentFormatContext.PageHeight)); 188value = Math.Max(1, Math.Min(value, structuralCache.CurrentFormatContext.PageHeight - pageMargin.Top - pageMargin.Bottom)); 256width = Math.Min(width, pageWidth);
MS\Internal\PtsHost\FigureParaClient.cs (4)
78_contentRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BPRight - mbp.BPLeft); 80_contentRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BPBottom - mbp.BPTop); 83_paddingRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BorderRight - mbp.BorderLeft); 85_paddingRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BorderBottom - mbp.BorderTop);
MS\Internal\PtsHost\FigureParagraph.cs (4)
155int subpageWidth = Math.Max(1, TextDpi.ToTextDpi(anchorLimitedWidth) - (mbp.BPLeft + mbp.BPRight)); 164int subpageHeight = Math.Max(1, TextDpi.ToTextDpi(anchorLimitedHeight) - (mbp.BPTop + mbp.BPBottom)); 611width = Math.Max(TextDpi.MinWidth, maxTotalWidth - elementMarginWidth); 640height = Math.Max(TextDpi.MinWidth, maxTotalHeight - elementMarginHeight);
MS\Internal\PtsHost\FloaterParaClient.cs (4)
200_contentRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BPRight - mbp.BPLeft); 202_contentRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BPBottom - mbp.BPTop); 205_paddingRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BorderRight - mbp.BorderLeft); 207_paddingRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BorderBottom - mbp.BorderTop);
MS\Internal\PtsHost\FloaterParagraph.cs (7)
212dvrAvailable = Math.Min(dvrAvailable, PTS.dvBottomUndefined / 2); 218dvrAvailable = Math.Min(dvrAvailable, TextDpi.ToTextDpi(StructuralCache.CurrentFormatContext.PageHeight)); 231subpageHeight = Math.Max(1, dvrAvailable - (mbp.MBPTop + mbp.MBPBottom)); 664subpageWidth = Math.Max(1, durSpecified - (mbp.BPLeft + mbp.BPRight)); 669subpageWidth = Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight)); 675subpageWidth = Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight)); 878return Math.Min(desiredSize, spaceAvailable);
MS\Internal\PtsHost\Line.cs (1)
104dvrSuppressible = Math.Max(0, TextDpi.ToTextDpi(_line.OverhangAfter));
MS\Internal\PtsHost\ListMarkerSourceInfo.cs (1)
195state.number = Math.DivRem(state.number, state.b, out int remainder) - state.disjoint;
MS\Internal\PtsHost\MarginCollapsingState.cs (2)
164_maxPositive = Math.Max(_maxPositive, mcs._maxPositive); 165_minNegative = Math.Min(_minNegative, mcs._minNegative);
MS\Internal\PtsHost\PtsHelper.cs (9)
833return Math.Max(1, Math.Min(PTS.Restrictions.tscColumnRestriction-1, columns)); // at least 1 column is required 880columnWidth = Math.Max(1, Math.Min(columnWidth, pageWidth)); 882freeSpace = Math.Max(0, freeSpace); 923pfscolinfo[i].durBefore = Math.Max(0, pfscolinfo[i].durBefore); 924pfscolinfo[i].durWidth = Math.Max(1, pfscolinfo[i].durWidth); 955pfscolinfo[i].durBefore = Math.Max(0, pfscolinfo[i].durBefore); 956pfscolinfo[i].durWidth = Math.Max(1, pfscolinfo[i].durWidth);
MS\Internal\PtsHost\PtsHost.cs (1)
1527for(int breakIndex = 0; breakIndex < Math.Min(textBreakpoints.Count, nLineVariantsAlloc); breakIndex++)
MS\Internal\PtsHost\PtsPage.cs (7)
772rect.dv = Math.Max(rect.dv, bbox.fsrc.dv); 775_calculatedSize.Width = Math.Max(TextDpi.MinWidth, TextDpi.FromTextDpi(rect.du)); 776_calculatedSize.Height = Math.Max(TextDpi.MinWidth, TextDpi.FromTextDpi(rect.dv)); 780_contentSize.Width = Math.Max(Math.Max(TextDpi.FromTextDpi(bbox.fsrc.du), TextDpi.MinWidth), _calculatedSize.Width); 781_contentSize.Height = Math.Max(TextDpi.MinWidth, TextDpi.FromTextDpi(bbox.fsrc.dv)); 787_contentSize.Height = Math.Max(_contentSize.Height, _calculatedSize.Height);
MS\Internal\PtsHost\SubpageParaClient.cs (4)
92_contentRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BPRight - mbp.BPLeft); 94_contentRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BPBottom - mbp.BPTop); 97_paddingRect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du - mbp.BorderRight - mbp.BorderLeft); 99_paddingRect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv - mbp.BorderBottom - mbp.BorderTop);
MS\Internal\PtsHost\SubpageParagraph.cs (16)
177subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight)); 186subpageHeight = Math.Max(1, subpageHeight - (marginTop + mbp.BPTop)); 240dvrUsed = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v); 241fsrcToFill.du = Math.Max(fsrcToFill.du, fsbbox.fsrc.du + fsbbox.fsrc.u); 284fsbbox.fsrc.du = Math.Max(fsrcToFill.du - (mbp.MarginLeft + mbp.MarginRight), 0); 285fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0); 364subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight)); 436dvrUsed = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v); 437durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u); 447fsbbox.fsrc.du = Math.Max(durTrack - (mbp.MarginLeft + mbp.MarginRight), 0); 448fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0); 524subpageWidth = Math.Max(1, subpageWidth - (mbp.MBPLeft + mbp.MBPRight)); 595dvrUsed = Math.Max(dvrUsed, fsbbox.fsrc.dv + fsbbox.fsrc.v); 596durTrack = Math.Max(durTrack, fsbbox.fsrc.du + fsbbox.fsrc.u); 606fsbbox.fsrc.du = Math.Max(durTrack - (mbp.MarginLeft + mbp.MarginRight), 0); 607fsbbox.fsrc.dv = Math.Max(dvrUsed - dvrTopSpace, 0);
MS\Internal\PtsHost\TableParaClient.cs (11)
646int du = Math.Min(Math.Abs(rect.u - u), Math.Abs(rect.u + rect.du - u)); 647int dv = Math.Min(Math.Abs(rect.v - v), Math.Abs(rect.v + rect.dv - v)); 995int iDistance = Math.Abs((cpc.Rect.u + cpc.Rect.du / 2) - suggestedU); 1071int iDistance = Math.Abs((cpc.Rect.u + cpc.Rect.du / 2) - suggestedU); 1928Math.Min(_calculatedColumns.Length, columns)); 2420Math.Max(_rect.du - (mbpInfo.BPRight + mbpInfo.BPLeft), 1), 2421Math.Max(_rect.dv - calculatedBPBottom - calculatedBPTop, 1)
MS\Internal\PtsHost\TextParaClient.cs (19)
739int dcpStart = Math.Max(cpStartTextPointer, cpParagraphStart) - cpParagraphStart; 743int dcpEnd = Math.Min(cpEndTextPointer, cpParagraphEnd) - cpParagraphStart; 1408int countVisualsShiftBeforeChange = Math.Min(Math.Max(lineIndexToBeginRemoval - _lineIndexFirstVisual, 0), lineVisuals.Count); 1425int actualLinesToRemove = Math.Min(Math.Max(lineIndexToBeginRemoval - _lineIndexFirstVisual + cLinesToRemove, 0), lineVisuals.Count); 1453int actualLinesToRemove = Math.Min(cLinesToRemove, lineVisuals.Count - (lineIndexToBeginRemoval - _lineIndexFirstVisual)); 1873int dcpRangeStartForThisLine = Math.Max(lineDesc.dcpFirst, dcpStart); 1876int cchRangeForThisLine = Math.Max(Math.Min(lineDesc.dcpLim, dcpEnd) - dcpRangeStartForThisLine, 1); 1983int dcpRangeStartForThisElem = Math.Max(elemDesc.dcpFirst, dcpStart); 1986int cchRangeForThisElem = Math.Max(Math.Min(elemDesc.dcpLim, dcpEnd) - dcpRangeStartForThisElem, 1); 2078lineRect.Width = Math.Max(lineVisual.WidthIncludingTrailingWhitespace, 0); 2189elementRect.Width = Math.Max(lineVisual.WidthIncludingTrailingWhitespace, 0); 3127line.GetGlyphRuns(glyphRuns, Math.Max(dcpStart, lineDesc.dcpFirst), Math.Min(dcpEnd, lineDesc.dcpLim)); 3189line.GetGlyphRuns(glyphRuns, Math.Max(dcpStart, element.dcpFirst), Math.Min(dcpEnd, element.dcpLim));
MS\Internal\PtsHost\TextParagraph.cs (2)
826ddcpOld = Math.Min(ddcpOld, (LastFormatCch - dcpStart) + 1); 827ddcpNew = Math.Min(ddcpNew, (Cch - dcpStart) + 1);
MS\Internal\PtsHost\UIElementParaClient.cs (2)
76_rect.du = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.du); 77_rect.dv = Math.Max(TextDpi.ToTextDpi(TextDpi.MinWidth), _rect.dv);
MS\Internal\PtsHost\UIElementParagraph.cs (3)
387double elementWidth = TextDpi.FromTextDpi(Math.Max(1, durAvailable - (mbp.MBPLeft + mbp.MBPRight))); 404elementHeight = Math.Max(TextDpi.FromTextDpi(1), elementHeight - TextDpi.FromTextDpi(mbp.MBPTop + mbp.MBPBottom)); 425elementHeight = Math.Max(TextDpi.FromTextDpi(1), elementHeight);
MS\Internal\Text\ComplexLine.cs (1)
558offset = Math.Min(_dcp + this.Length, offset);
MS\Internal\Text\DynamicPropertyReader.cs (2)
211return Math.Max(TextDpi.MinWidth, Math.Min(TextDpi.MaxWidth, lineHeight));
MS\Internal\Text\LineProperties.cs (2)
183lineAdvance = Math.Max(lineAdvance, _lineHeight); 215lineAdvance = Math.Max(lineAdvance, _lineHeight);
MS\Internal\Text\SimpleLine.cs (1)
84Math.Min(dcp, _content.Length)
MS\Internal\Text\TextDpi.cs (3)
51return (int)Math.Round(d * _scale); 164pageMargin.Right = Math.Max(0.0, pageSize.Width - pageMargin.Left - _minSize); 173pageMargin.Bottom = Math.Max(0.0, pageSize.Height - pageMargin.Top - _minSize);;
MS\Internal\WindowsRuntime\Generated\WinRT\Projections\IReadOnlyList.cs (1)
184uint itemCount = Math.Min((uint)items.Length, (uint)_list.Count - startIndex);
System\Windows\Application.cs (1)
2452if (Math.Abs(diff) == 1)
System\Windows\Automation\Peers\CalendarAutomationPeer.cs (1)
356return Math.Max(0, this.OwningGrid.RowDefinitions.Count - 1);
System\Windows\Automation\Peers\ScrollViewerAutomationPeer.cs (3)
209return Math.Min(100.0, (double)(owner.ViewportWidth * 100.0 / owner.ExtentWidth)); 223return Math.Min(100.0, (double)(owner.ViewportHeight * 100.0 / owner.ExtentHeight)); 259return Math.Min(100.0, (double)(viewport * 100.0 / extent));
System\Windows\Controls\Border.cs (12)
230Size childConstraint = new Size(Math.Max(0.0, constraint.Width - combined.Width), 231Math.Max(0.0, constraint.Height - combined.Height)); 635Math.Max(0.0, rt.Width - thick.Left - thick.Right), 636Math.Max(0.0, rt.Height - thick.Top - thick.Bottom)); 979LeftTop = Math.Max(0.0, radii.TopLeft - left); 980TopLeft = Math.Max(0.0, radii.TopLeft - top); 981TopRight = Math.Max(0.0, radii.TopRight - top); 982RightTop = Math.Max(0.0, radii.TopRight - right); 983RightBottom = Math.Max(0.0, radii.BottomRight - right); 984BottomRight = Math.Max(0.0, radii.BottomRight - bottom); 985BottomLeft = Math.Max(0.0, radii.BottomLeft - bottom); 986LeftBottom = Math.Max(0.0, radii.BottomLeft - left);
System\Windows\Controls\ColumnDefinition.cs (1)
636PrivateSetCapacity(Math.Max(_items.Length * 2, c_defaultCapacity));
System\Windows\Controls\DataGrid.cs (18)
2647indexToSelect = Math.Min(Items.Count - numSelected - 1, indexToSelect); 5070int newRowCount = Math.Abs(endIndex - startIndex) + 1; 5071int newColumnCount = Math.Abs(endColumnIndex - startColumnIndex) + 1; 5089int previousStartIndex = Math.Min(startIndex, currentCellIndex); 5090int previousRowCount = Math.Abs(currentCellIndex - startIndex) + 1; 5091int previousStartColumnIndex = Math.Min(startColumnIndex, currentCellColumnIndex); 5092int previousColumnCount = Math.Abs(currentCellColumnIndex - startColumnIndex) + 1; 5132_selectedCells.AddRegion(Math.Min(startIndex, endIndex), Math.Min(startColumnIndex, endColumnIndex), newRowCount, newColumnCount); 5730nextDisplayIndex = Math.Max(0, InternalColumns.LastVisibleDisplayIndex); 5811nextRowIndex = Math.Max(0, Items.Count - 1); 5996index = Math.Max(0, Math.Min(numItems - 1, index + (shiftModifier ? -1 : 1))); 6139int jumpDistance = Math.Max(1, (int)scrollHost.ViewportHeight - 1); 6141targetIndex = Math.Max(0, Math.Min(targetIndex, Items.Count - 1)); 6584distance = Math.Abs(pt.Y - cellBounds.Top); 6592distance = Math.Abs(pt.X - cellBounds.Left);
System\Windows\Controls\DataGridCellsPanel.cs (6)
186measureHeight = Math.Max(measureHeight, blockMeasureSize.Height); 398measureSize.Height = Math.Max(measureSize.Height, childSize.Height); 418measureSize.Height = Math.Max(measureSize.Height, headerSize.Height); 613measureHeight = Math.Max(measureHeight, childSize.Height); 1904childMeasureWidth = Math.Max(averageColumnWidth, column.MinWidth); 1905childMeasureWidth = Math.Min(childMeasureWidth, column.MaxWidth);
System\Windows\Controls\DataGridColumnCollection.cs (24)
749int columnCount = Math.Min(newFrozenCount, Count); 757int columnCount = Math.Min(oldFrozenCount, Count); 947availableStarSpace = Math.Max(0.0, availableStarSpace - columnMinWidth); 1231double displayValue = Math.Max(width.DesiredValue, minWidth); 1271double displayValue = Math.Min(width.DesiredValue, maxWidth); 1339TakeAwayWidthFromColumns(null, Math.Abs(availableSpaceChange), false, newTotalAvailableSpace); 1363column.SetWidthInternal(new DataGridLength(width.Value, width.UnitType, width.DesiredValue, Math.Min(width.DesiredValue, maxWidth))); 1385Math.Max(width.DisplayValue - nonRetrievableSpace, changedColumn.MinWidth))); 1457return Math.Max(availableSpace - requiredSpace, 0.0); 1668column.UpdateWidthForStarColumn(Math.Max(columnDesiredWidth, column.MinWidth), columnDesiredWidth, columnDesiredWidth / perStarWidth); 1697double columnExcessWidth = onlyShrinkToDesiredWidth ? width.DisplayValue - Math.Max(width.DesiredValue, column.MinWidth) : width.DisplayValue - column.MinWidth; 1782double maxColumnResizeWidth = expandBeyondDesiredWidth ? column.MaxWidth : Math.Min(width.DesiredValue, column.MaxWidth); 1917column.UpdateWidthForStarColumn(Math.Min(columnDesiredWidth, column.MaxWidth), columnDesiredWidth, columnDesiredWidth / perStarWidth); 2004double usedStarSpace = ComputeStarColumnWidths(Math.Min(expectedStarSpace, sumOfStarMaxWidths)); 2005giveAwayWidth = Math.Max(usedStarSpace - expectedStarSpace, 0.0); 2075double lagWidth = Math.Min(width.DesiredValue, columnMaxWidth) - width.DisplayValue; 2106if (DoubleUtil.LessThan(width.DisplayValue, Math.Min(width.DesiredValue, column.MaxWidth))) 2134giveAwayWidth -= Math.Min(contributingSpace, giveAwayWidth); 2141giveAwayWidth = Math.Min(giveAwayWidth, Math.Max(0d, totalSpace - usedSpace)); 2188return Math.Min(usedSpace - totalAvailableWidth, takeAwayWidth); 2196takeAwayWidth = Math.Max(0.0, takeAwayWidth - unusedSpace); 2267double usedStarSpace = ComputeStarColumnWidths(Math.Max(expectedStarSpace, sumOfStarMinWidths)); 2268takeAwayWidth = Math.Max(usedStarSpace - expectedStarSpace, 0.0);
System\Windows\Controls\DataGridHelper.cs (4)
33return new Size(size.Width, Math.Max(0.0, size.Height - thickness)); 37return new Size(Math.Max(0.0, size.Width - thickness), size.Height); 716value = Math.Max(value, minValue); 717value = Math.Min(value, maxValue);
System\Windows\Controls\DataGridRow.cs (1)
549double minHeight = Math.Max(RowHeader.DesiredSize.Height, MinHeight);
System\Windows\Controls\DefinitionBase.cs (2)
126_minSize = Math.Max(_minSize, minSize); 876sharedMinSize = Math.Max(sharedMinSize, _registry[i]._minSize);
System\Windows\Controls\DockPanel.cs (10)
220childConstraint = new Size(Math.Max(0.0, constraint.Width - accumulatedWidth), 221Math.Max(0.0, constraint.Height - accumulatedHeight)); 241parentHeight = Math.Max(parentHeight, accumulatedHeight + childDesiredSize.Height); 247parentWidth = Math.Max(parentWidth, accumulatedWidth + childDesiredSize.Width); 254parentWidth = Math.Max(parentWidth, accumulatedWidth); 255parentHeight = Math.Max(parentHeight, accumulatedHeight); 285Math.Max(0.0, arrangeSize.Width - (accumulatedLeft + accumulatedRight)), 286Math.Max(0.0, arrangeSize.Height - (accumulatedTop + accumulatedBottom)) ); 299rcChild.X = Math.Max(0.0, arrangeSize.Width - accumulatedRight); 310rcChild.Y = Math.Max(0.0, arrangeSize.Height - accumulatedBottom);
System\Windows\Controls\DocumentViewer.cs (2)
1396VerticalOffset = Math.Max(verticalOffset, 0.0); 1397HorizontalOffset = Math.Max(horizontalOffset, 0.0);
System\Windows\Controls\FlowDocumentReader.cs (2)
717SetCurrentValueInternal(ZoomProperty, Math.Min(Zoom + ZoomIncrement, MaxZoom)); 729SetCurrentValueInternal(ZoomProperty, Math.Max(Zoom - ZoomIncrement, MinZoom));
System\Windows\Controls\FlowDocumentScrollViewer.cs (8)
589Math.Max(ia.OriginWidth, pagePadding.Left), 590Math.Max(ia.OriginHeight, pagePadding.Top), 591Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right), 592Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom)); 631Zoom = Math.Min(Zoom + ZoomIncrement, MaxZoom); 643Zoom = Math.Max(Zoom - ZoomIncrement, MinZoom); 709SetCurrentValueInternal(ZoomProperty, Math.Min(Zoom + ZoomIncrement, MaxZoom)); 713SetCurrentValueInternal(ZoomProperty, Math.Max(Zoom - ZoomIncrement, MinZoom));
System\Windows\Controls\Grid.cs (69)
371gridDesiredSize.Width = Math.Max(gridDesiredSize.Width, child.DesiredSize.Width); 372gridDesiredSize.Height = Math.Max(gridDesiredSize.Height, child.DesiredSize.Height); 908cell.ColumnIndex = Math.Min(GetColumn(child), DefinitionsU.Length - 1); 911cell.RowIndex = Math.Min(GetRow(child), DefinitionsV.Length - 1); 916cell.ColumnSpan = Math.Min(GetColumnSpan(child), DefinitionsU.Length - cell.ColumnIndex); 920cell.RowSpan = Math.Min(GetRowSpan(child), DefinitionsV.Length - cell.RowIndex); 1097userMinSize = Math.Max(userMinSize, Math.Min(userSize, userMaxSize)); 1121definitions[i].MeasureSize = Math.Max(userMinSize, Math.Min(userSize, userMaxSize)); 1221DefinitionsU[PrivateCells[i].ColumnIndex].UpdateMinSize(Math.Min(children[i].DesiredSize.Width, DefinitionsU[PrivateCells[i].ColumnIndex].UserMaxSize)); 1238DefinitionsV[PrivateCells[i].RowIndex].UpdateMinSize(Math.Min(children[i].DesiredSize.Height, DefinitionsV[PrivateCells[i].RowIndex].UserMaxSize)); 1459double maxSize = Math.Max(definitions[i].UserMaxSize, minSize); 1511double newMinSize = Math.Min(sizeToDistribute / (count - i), tempDefinitions[i].PreferredSize); 1541tempDefinitions[i].UpdateMinSize(Math.Min(newMinSize, tempDefinitions[i].SizeCache)); 1552tempDefinitions[i].UpdateMinSize(Math.Min(newMinSize, tempDefinitions[i].SizeCache)); 1663starValue = Math.Min(starValue, c_starClip); 1667double maxSize = Math.Max(definitions[i].MinSize, definitions[i].UserMaxSize); 1668maxSize = Math.Min(maxSize, c_starClip); 1706double userSize = Math.Max(availableSize - takenSize, 0.0) * (starValue / tempDefinitions[i].SizeCache); 1707resolvedSize = Math.Min(userSize, tempDefinitions[i].UserMaxSize); 1708resolvedSize = Math.Max(tempDefinitions[i].MinSize, resolvedSize); 1769double power = Math.Floor(Math.Log(Double.MaxValue / maxStar / starCount, 2.0)); 1772scale = Math.Pow(2.0, power - 4.0); // -4 is just for paranoia 1820double effectiveMaxSize = Math.Max(def.MinSize, def.UserMaxSize); 1892resolvedSize = Math.Max(resolvedDef.MinSize, resolvedDef.UserMaxSize); 2010double resolvedSize = (def.MeasureSize > 0.0) ? Math.Max(availableSize - takenSize, 0.0) * (def.MeasureSize / def.SizeCache) : 0.0; 2013resolvedSize = Math.Min(resolvedSize, def.UserMaxSize); 2014resolvedSize = Math.Max(def.MinSize, resolvedSize); 2103starValue = Math.Min(starValue, c_starClip); 2107double maxSize = Math.Max(definitions[i].MinSizeForArrange, definitions[i].UserMaxSize); 2108maxSize = Math.Min(maxSize, c_starClip); 2148definitions[i].SizeCache = Math.Max(definitions[i].MinSizeForArrange, Math.Min(userSize, userMaxSize)); 2193double userSize = Math.Max(finalSize - allPreferredArrangeSize, 0.0) * (starValue / definitions[definitionIndices[i]].SizeCache); 2194resolvedSize = Math.Min(userSize, definitions[definitionIndices[i]].UserMaxSize); 2195resolvedSize = Math.Max(definitions[definitionIndices[i]].MinSizeForArrange, resolvedSize); 2220final = Math.Max(final, definitions[definitionIndex].MinSizeForArrange); 2221final = Math.Min(final, definitions[definitionIndex].SizeCache); 2227final = Math.Max(final, definitions[definitionIndex].MinSizeForArrange); 2228final = Math.Min(final, definitions[definitionIndex].SizeCache); 2261final = Math.Max(final, definition.MinSizeForArrange); 2277final = Math.Max(final, definition.MinSizeForArrange); 2348double power = Math.Floor(Math.Log(Double.MaxValue / maxStar / starCount, 2.0)); 2351scale = Math.Pow(2.0, power - 4.0); // -4 is just for paranoia 2395double effectiveMaxSize = Math.Max(def.MinSizeForArrange, def.UserMaxSize); 2434def.SizeCache = Math.Max(def.MinSizeForArrange, Math.Min(userSize, userMaxSize)); 2503resolvedSize = Math.Max(resolvedDef.MinSizeForArrange, resolvedDef.UserMaxSize); 2635double resolvedSize = (def.MeasureSize > 0.0) ? Math.Max(finalSize - takenSize, 0.0) * (def.MeasureSize / def.SizeCache) : 0.0; 2638resolvedSize = Math.Min(resolvedSize, def.UserMaxSize); 2639resolvedSize = Math.Max(def.MinSizeForArrange, resolvedSize); 2730final = Math.Max(final, definition.MinSizeForArrange); 2746final = Math.Max(final, definition.MinSizeForArrange); 2788double minPower = Math.Floor(Math.Log(minRatio, 2.0)); 2789double maxPower = Math.Floor(Math.Log(maxRatio, 2.0)); 2790double f = Math.Pow(2.0, Math.Floor((minPower + maxPower) / 2.0)); 2869Array.Clear(extData.TempDefinitions, 0, Math.Max(DefinitionsU.Length, DefinitionsV.Length)); 3074int requiredLength = Math.Max(DefinitionsU.Length, DefinitionsV.Length) * 2; 3107int requiredLength = Math.Max(Math.Max(DefinitionsU.Length, DefinitionsV.Length), 1) * 2; 3125int requiredLength = Math.Max(DefinitionsU.Length, DefinitionsV.Length); 3217return (Math.Abs(d) < c_epsilon); 3228return (Math.Abs(d1 - d2) < c_epsilon);
System\Windows\Controls\GridSplitter.cs (13)
498_resizeData.SplitterLength = Math.Min(ActualWidth, ActualHeight); 650horizontalChange = Math.Round(horizontalChange / dragIncrement) * dragIncrement; 651verticalChange = Math.Round(verticalChange / dragIncrement) * dragIncrement; 658_resizeData.Adorner.OffsetX = Math.Min(Math.Max(horizontalChange, _resizeData.MinChange), _resizeData.MaxChange); 662_resizeData.Adorner.OffsetY = Math.Min(Math.Max(verticalChange, _resizeData.MinChange), _resizeData.MaxChange); 796definition1Min = Math.Max(definition1Min, _resizeData.SplitterLength); 800definition2Min = Math.Max(definition2Min, _resizeData.SplitterLength); 806minDelta = -Math.Min(definition1Len - definition1Min, definition2Max - definition2Len); 807maxDelta = Math.Min(definition1Max - definition1Len, definition2Len - definition2Min); 915delta = Math.Min(Math.Max(delta, min), max);
System\Windows\Controls\GridViewHeaderRowPresenter.cs (8)
259double childConstraintWidth = Math.Max(0.0, constraint.Width - accumulatedWidth); 281childConstraintWidth = Math.Min(childConstraintWidth, column.DesiredWidth); 289childConstraintWidth = Math.Min(childConstraintWidth, column.Width); 296maxHeight = Math.Max(maxHeight, child.DesiredSize.Height); 303maxHeight = Math.Max(maxHeight, _paddingHeader.DesiredSize.Height); 352double childArrangeWidth = Math.Min(remainingWidth, ((column.State == ColumnMeasureState.SpecificWidth) ? column.Width : column.DesiredWidth)); 386rect = new Rect(accumulatedWidth, 0.0, Math.Max(remainingWidth, 0.0), arrangeSize.Height); 1244return (DoubleUtil.GreaterThan(Math.Abs(currentPos.X - originalPos.X), c_thresholdX));
System\Windows\Controls\GridViewRowPresenter.cs (5)
144double childConstraintWidth = Math.Max(0.0, constraint.Width - accumulatedWidth); 173childConstraintWidth = Math.Min(childConstraintWidth, column.DesiredWidth); 181childConstraintWidth = Math.Min(childConstraintWidth, column.Width); 188maxHeight = Math.Max(maxHeight, child.DesiredSize.Height); 221double childArrangeWidth = Math.Min(remainingWidth, ((column.State == ColumnMeasureState.SpecificWidth) ? column.Width : column.DesiredWidth));
System\Windows\Controls\InkPresenter.cs (4)
170newSize.Width = Math.Max(newSize.Width, sizeStrokes.Width); 171newSize.Height = Math.Max(newSize.Height, sizeStrokes.Height); 204availableSize = new Size(Math.Min(arrangeSize.Width, _constraintSize.Width), 205Math.Min(arrangeSize.Height, _constraintSize.Height));
System\Windows\Controls\ItemContainerGenerator.cs (1)
2758int index = Math.Min(oldIndex, newIndex);
System\Windows\Controls\ItemsControl.cs (2)
2802return FindFocusable((int)(ScrollHost.VerticalOffset + Math.Max(ScrollHost.ViewportHeight - 1, 0)), 2816return FindFocusable((int)(ScrollHost.HorizontalOffset + Math.Max(ScrollHost.ViewportWidth - 1, 0)),
System\Windows\Controls\MenuScrollingVisibilityConverter.cs (2)
84double percent = Math.Min(100.0, Math.Max(0.0, (verticalOffset * 100.0 / (extentHeight - viewportHeight))));
System\Windows\Controls\PasswordTextNavigator.cs (2)
196finalCount = Math.Min(count, _container.SymbolCount - _offset); 200finalCount = Math.Min(count, _offset);
System\Windows\Controls\PopupControlService.cs (2)
1605Debug.Assert(((int)pt.X == (int)Math.Round(pt2.X)) && ((int)pt.Y == (int)Math.Round(pt2.Y)), "got incorrect mouse point");
System\Windows\Controls\Primitives\BulletDecorator.cs (5)
252contentConstraint.Width = Math.Max(0.0, contentConstraint.Width - bulletSize.Width); 258Size desiredSize = new Size(bulletSize.Width + contentSize.Width, Math.Max(bulletSize.Height, contentSize.Height)); 294contentSize.Width = Math.Max(content.DesiredSize.Width, arrangeSize.Width - bullet.DesiredSize.Width); 295contentSize.Height = Math.Max(content.DesiredSize.Height, arrangeSize.Height); 300bulletOffsetY += Math.Max(0d, centerY - bulletSize.Height * 0.5d);
System\Windows\Controls\Primitives\DataGridCellsPresenter.cs (1)
129dirtyCount = Math.Min(newColumnCount, oldColumnCount);
System\Windows\Controls\Primitives\DataGridColumnHeadersPresenter.cs (10)
117desiredSize.Width = Math.Max(desiredSize.Width, indicatorSize.Width); 118desiredSize.Height = Math.Max(desiredSize.Height, indicatorSize.Height); 125desiredSize.Width = Math.Max(desiredSize.Width, indicatorSize.Width); 126desiredSize.Height = Math.Max(desiredSize.Height, indicatorSize.Height); 129desiredSize.Width = Math.Min(availableSize.Width, desiredSize.Width); 149childRect.Width = Math.Max(finalSize.Width, dataGrid.CellsPanelActualWidth); 644return DoubleUtil.GreaterThan(Math.Abs(currentPos.X - originalPos.X), SystemParameters.MinimumHorizontalDragDistance); 693height = Math.Max(_draggingSrcColumnHeader.RenderSize.Height, _columnHeaderDragIndicator.Height); 917columnEstimatedWidth = Math.Max(averageColumnWidth, column.MinWidth); 918columnEstimatedWidth = Math.Min(columnEstimatedWidth, column.MaxWidth);
System\Windows\Controls\Primitives\DocumentPageView.cs (2)
958pageVisualRect.Width = Math.Min(pageVisualRect.Width, maxWidth); 959pageVisualRect.Height = Math.Min(pageVisualRect.Height, maxHeight);
System\Windows\Controls\Primitives\Popup.cs (26)
2102if (Math.Abs(score - childArea) < Tolerance) 2128if (Math.Abs(intersection.Width - childBounds.Width) > Tolerance || 2129Math.Abs(intersection.Height - childBounds.Height) > Tolerance) 2143if (!IsTransparent || double.IsNaN(horizontalAxis.Y) || Math.Abs(horizontalAxis.Y) < Tolerance) 2155else if (IsTransparent && Math.Abs(horizontalAxis.X) < Tolerance) 2178if (!IsTransparent || double.IsNaN(verticalAxis.X) || Math.Abs(verticalAxis.X) < Tolerance) 2189else if (IsTransparent && Math.Abs(verticalAxis.Y) < Tolerance) 2244if (!IsTransparent || double.IsNaN(verticalAxis.X) || Math.Abs(verticalAxis.X) < Tolerance) 2246limitSize.Height = Math.Max(0.0, Math.Max(screenBounds.Bottom - targetBounds.Bottom, targetBounds.Top - screenBounds.Top)); 2248else if (IsTransparent && Math.Abs(verticalAxis.Y) < Tolerance) 2250limitSize.Width = Math.Max(0.0, Math.Max(screenBounds.Right - targetBounds.Right, targetBounds.Left - screenBounds.Left)); 2266if (!IsTransparent || double.IsNaN(horizontalAxis.X) || Math.Abs(horizontalAxis.Y) < Tolerance) 2268limitSize.Width = Math.Max(0.0, Math.Max(screenBounds.Right - targetBounds.Right, targetBounds.Left - screenBounds.Left)); 2270else if (IsTransparent && Math.Abs(horizontalAxis.X) < Tolerance) 2272limitSize.Height = Math.Max(0.0, Math.Max(screenBounds.Bottom - targetBounds.Bottom, targetBounds.Top - screenBounds.Top)); 2622desiredSize.Width = Math.Min(desiredSize.Width, screenBounds.Width); 2623desiredSize.Width = Math.Min(desiredSize.Width, limitSize.Width); 2627desiredSize.Height = Math.Min(desiredSize.Height, screenBounds.Height); 2628desiredSize.Height = Math.Min(desiredSize.Height, maxHeight); 2629desiredSize.Height = Math.Min(desiredSize.Height, limitSize.Height); 2701return new Rect(mousePoint.x, mousePoint.y - 1, Math.Max(0, cursorWidth - hotX), Math.Max(0, cursorHeight - hotY + 2));
System\Windows\Controls\Primitives\PopupRoot.cs (4)
218restrictWidth = Math.Abs(restrictedSize.Width - desiredSize.Width) > Popup.Tolerance; 219restrictHeight = Math.Abs(restrictedSize.Height - desiredSize.Height) > Popup.Tolerance; 230return new Size(Math.Min(restrictedSize.Width, restricted2DDesiredSize.Width), 231Math.Min(restrictedSize.Height, restricted2DDesiredSize.Height));
System\Windows\Controls\Primitives\ScrollBar.cs (8)
333perpendicularDragDelta = Math.Abs(verticalDragDelta); 337perpendicularDragDelta = Math.Abs(horizontalDragDelta); 409newValue = Math.Min(Math.Max(newValue, Minimum), Maximum); 539double newValue = Math.Max(Value - SmallChange, Minimum); 548double newValue = Math.Min(Value + SmallChange, Maximum); 557double newValue = Math.Max(Value - LargeChange, Minimum); 566double newValue = Math.Min(Value + LargeChange, Maximum);
System\Windows\Controls\Primitives\ScrollContentPresenter.cs (5)
435desiredSize.Width = Math.Min(constraint.Width, desiredSize.Width); 436desiredSize.Height = Math.Min(constraint.Height, desiredSize.Height); 484childRect.Width = Math.Max(childRect.Width, arrangeSize.Width); 485childRect.Height = Math.Max(childRect.Height, arrangeSize.Height); 687return Math.Max(0.0, offset);
System\Windows\Controls\Primitives\TabPanel.cs (5)
204desiredSizeWithoutMargin.Height = Math.Max(0d, element.DesiredSize.Height - margin.Top - margin.Bottom); 205desiredSizeWithoutMargin.Width = Math.Max(0d, element.DesiredSize.Width - margin.Left - margin.Right); 276childSize.Height = Math.Max(0d, childSize.Height - topOffset - bottomOffset); 277childSize.Width = Math.Max(0d, childSize.Width - leftOffset - rightOffset); 408currentAverageGap = Math.Max(0d, (rowWidthLimit - currentRowWidth) / numberOfHeadersInCurrentRow); // The amout of width that should be added to justify the header
System\Windows\Controls\Primitives\TickBar.cs (4)
521Point pt2 = new Point(startPoint.X + tickLen2, y0 + Math.Abs(tickLen2) * progression); 534pt2 = new Point(startPoint.X + tickLen2, y0 - Math.Abs(tickLen2) * progression); 626Point pt2 = new Point(x0 + Math.Abs(tickLen2) * progression, startPoint.Y + tickLen2); 639pt2 = new Point(x0 - Math.Abs(tickLen2) * progression, startPoint.Y + tickLen2);
System\Windows\Controls\Primitives\ToolBarOverflowPanel.cs (7)
112_wrapWidth = Math.Min(_wrapWidth, constraint.Width); 121_panelSize.Width = Math.Max(curLineSize.Width, _panelSize.Width); 127_panelSize.Width = Math.Max(sz.Width, _panelSize.Width); 135curLineSize.Height = Math.Max(sz.Height, curLineSize.Height); 140_panelSize.Width = Math.Max(curLineSize.Width, _panelSize.Width); 156_wrapWidth = Math.Min(_wrapWidth, arrangeBounds.Width); 176curLineSize.Height = Math.Max(sz.Height, curLineSize.Height);
System\Windows\Controls\Primitives\ToolBarPanel.cs (6)
116panelDesiredSize.Height = Math.Max(panelDesiredSize.Height, childDesiredSize.Height); 120panelDesiredSize.Width = Math.Max(panelDesiredSize.Width, childDesiredSize.Width); 175panelDesiredSize.Height = Math.Max(panelDesiredSize.Height, childDesiredSize.Height); 180panelDesiredSize.Width = Math.Max(panelDesiredSize.Width, childDesiredSize.Width); 304rcChild.Height = Math.Max(arrangeSize.Height, child.DesiredSize.Height); 311rcChild.Width = Math.Max(arrangeSize.Width, child.DesiredSize.Width);
System\Windows\Controls\Primitives\Track.cs (11)
71return Math.Max(Minimum, Math.Min(Maximum, val)); 471double viewportSize = Math.Max(0.0, ViewportSize); 570double range = Math.Max(0.0, Maximum - min); 571double offset = Math.Min(range, Value - min); 609double range = Math.Max(0.0, Maximum - min); 610double offset = Math.Min(range, Value - min); 614double extent = Math.Max(0.0, range) + viewportSize; 626thumbMinLength = Math.Floor(buttonHeight * 0.5); 634thumbMinLength = Math.Floor(buttonWidth * 0.5); 640thumbLength = Math.Max(thumbMinLength, thumbLength);
System\Windows\Controls\Primitives\UniformGrid.cs (1)
289_rows = (int)Math.Sqrt(nonCollapsedCount);
System\Windows\Controls\PrintDialog.cs (6)
298dlg.MinPage = Math.Max(1, Math.Min(_minPage, _maxPage)); 299dlg.MaxPage = Math.Max(dlg.MinPage, Math.Max(_minPage, _maxPage)); 305Math.Max((int)dlg.MinPage, _pageRange.PageFrom), 306Math.Min((int)dlg.MaxPage, _pageRange.PageTo));
System\Windows\Controls\RowDefinition.cs (1)
636PrivateSetCapacity(Math.Max(_items.Length * 2, c_defaultCapacity));
System\Windows\Controls\ScrollViewer.cs (17)
401get { return Math.Max(0.0, ExtentWidth - ViewportWidth); } 409get { return Math.Max(0.0, ExtentHeight - ViewportHeight); } 1749DoubleUtil.LessThan(Math.Abs(unusedX), PanningInfo.PreFeedbackTranslationX)) 1757DoubleUtil.LessThan(Math.Abs(unusedY), PanningInfo.PreFeedbackTranslationY)) 1802double newUnused = Math.Max(unused + delta, 0); 1811double newUnused = Math.Min(unused + delta, 0); 1822Math.Round(PanningRatio * cumulativeTranslation / _panningInfo.DeltaPerHorizontalOffet)); 1832Math.Round(PanningRatio * cumulativeTranslation / _panningInfo.DeltaPerVerticalOffset)); 1845if (Math.Abs(Environment.TickCount - _panningInfo.InertiaBoundaryBeginTimestamp) < PanningInfo.InertiaBoundryMinimumTicks) 1850return (DoubleUtil.GreaterThanOrClose(Math.Abs(_panningInfo.UnusedTranslation.X), PanningInfo.MaxInertiaBoundaryTranslation) || 1851DoubleUtil.GreaterThanOrClose(Math.Abs(_panningInfo.UnusedTranslation.Y), PanningInfo.MaxInertiaBoundaryTranslation)); 1870bool validX = (DoubleUtil.GreaterThan(Math.Abs(translation.X), PanningInfo.PrePanTranslation)); 1871bool validY = (DoubleUtil.GreaterThan(Math.Abs(translation.Y), PanningInfo.PrePanTranslation)); 1881bool biggerX = (DoubleUtil.GreaterThanOrClose(Math.Abs(translation.X), Math.Abs(translation.Y))); 1894bool biggerY = (DoubleUtil.GreaterThanOrClose(Math.Abs(translation.Y), Math.Abs(translation.X)));
System\Windows\Controls\SinglePageViewer.cs (6)
701Math.Max(ia.OriginWidth, pagePadding.Left), 702Math.Max(ia.OriginHeight, pagePadding.Top), 703Math.Max(ia.MediaSizeWidth - (ia.OriginWidth + ia.ExtentWidth), pagePadding.Right), 704Math.Max(ia.MediaSizeHeight - (ia.OriginHeight + ia.ExtentHeight), pagePadding.Bottom)); 742SetCurrentValueInternal(ZoomProperty, Math.Min(Zoom + ZoomIncrement, MaxZoom)); 754SetCurrentValueInternal(ZoomProperty, Math.Max(Zoom - ZoomIncrement, MinZoom));
System\Windows\Controls\Slider.cs (15)
1007valueToSize = Math.Max(0.0, (trackSize.Width - thumbSize.Width) / range); 1013Canvas.SetLeft(rangeElement, (thumbSize.Width * 0.5) + Math.Max(Maximum - SelectionEnd, 0) * valueToSize); 1017Canvas.SetLeft(rangeElement, (thumbSize.Width * 0.5) + Math.Max(SelectionStart - Minimum, 0) * valueToSize); 1029valueToSize = Math.Max(0.0, (trackSize.Height - thumbSize.Height) / range); 1035Canvas.SetTop(rangeElement, (thumbSize.Height * 0.5) + Math.Max(SelectionStart - Minimum, 0) * valueToSize); 1039Canvas.SetTop(rangeElement, (thumbSize.Height * 0.5) + Math.Max(Maximum - SelectionEnd,0) * valueToSize); 1072valueToSize = Math.Max(0.0, (trackSize.Width - thumbSize.Width) / range); 1096valueToSize = Math.Max(0.0, (trackSize.Height - thumbSize.Height) / range); 1204previous = Minimum + (Math.Round(((value - Minimum) / TickFrequency)) * TickFrequency); 1205next = Math.Min(Maximum, previous + TickFrequency); 1225double next = SnapToTick(Math.Max(this.Minimum, Math.Min(this.Maximum, value + direction))); 1263double tickNumber = Math.Round((value - Minimum) / TickFrequency); 1424this.SetCurrentValueInternal(ValueProperty, Math.Max(this.Minimum, Math.Min(this.Maximum, snappedValue)));
System\Windows\Controls\Stack.cs (15)
598stackDesiredSize.Height = Math.Max(stackDesiredSize.Height, childDesiredSize.Height); 603stackDesiredSize.Width = Math.Max(stackDesiredSize.Width, childDesiredSize.Width); 663offset.Y = Math.Max(0, Math.Min(offset.Y, extent.Height - viewport.Height)); 671offset.X = Math.Max(0, Math.Min(offset.X, extent.Width - viewport.Width)); 676stackDesiredSize.Width = Math.Min(stackDesiredSize.Width, constraint.Width); 677stackDesiredSize.Height = Math.Min(stackDesiredSize.Height, constraint.Height); 755rcChild.Height = Math.Max(arrangeSize.Height, child.DesiredSize.Height); 762rcChild.Width = Math.Max(arrangeSize.Width, child.DesiredSize.Width); 896double left = Math.Max(targetRectOffset, minPhysicalOffset); 897targetRectSize = Math.Max(Math.Min(targetRectSize + targetRectOffset, minPhysicalOffset + viewportSize) - left, 0); 995iNewOffset = Math.Max(Math.Min(numberOfItems - 1, iNewOffset), 0);
System\Windows\Controls\StickyNote.cs (4)
1134horizontalChange = Math.Min(Math.Max(minBoundary.X, horizontalChange), maxBoundary.X); 1135verticalChange = Math.Min(Math.Max(minBoundary.Y, verticalChange), maxBoundary.Y);
System\Windows\Controls\TextBlock.cs (12)
1265Size contentSize = new Size(Math.Max(0.0, constraint.Width - (padding.Left + padding.Right)), 1266Math.Max(0.0, constraint.Height - (padding.Top + padding.Bottom))); 1305desiredSize.Width = Math.Max(desiredSize.Width, line.GetCollapsedWidth()); 1531double contentBottom = Math.Max(0.0, RenderSize.Height - Padding.Bottom); 1968Size contentSize = new Size(Math.Max(0.0, _referenceSize.Width - (padding.Left + padding.Right)), 1969Math.Max(0.0, _referenceSize.Height - (padding.Top + padding.Bottom))); 2321int dcpStart = Math.Max(dcpLineStart, dcpPositionStart); 2322int dcpEnd = Math.Min(dcpLineEnd, dcpPositionEnd); 3106Size contentSize = new Size(Math.Max(0.0, computedSize.Width - (padding.Left + padding.Right)), 3107Math.Max(0.0, computedSize.Height - (padding.Top + padding.Bottom))); 3156double contentBottom = Math.Max(0.0, RenderSize.Height - Padding.Bottom); 3186width = Math.Max(0.0, width - paddingWidth);
System\Windows\Controls\TextBox.cs (3)
326return (int)Math.Floor((this.VerticalOffset / lineHeight) + epsilon); 350return (int)Math.Floor((this.VerticalOffset + this.ViewportHeight - 1) / GetLineHeight()); 1722if ( 2*(prefix + suffix) >= Math.Min(oldText.Length, newText.Length))
System\Windows\Controls\TextRangeAdaptor.cs (1)
993int absCount = (count == int.MinValue) ? int.MaxValue : Math.Abs(count);
System\Windows\Controls\ToolBar.cs (2)
549extraLength = Math.Max(0.0, desiredSize.Width - toolBarPanel.DesiredSize.Width + margin.Left + margin.Right); 553extraLength = Math.Max(0.0, desiredSize.Height - toolBarPanel.DesiredSize.Height + margin.Top + margin.Bottom);
System\Windows\Controls\ToolBarTray.cs (5)
381bandThickness = Math.Max(bandThickness, fHorizontal ? toolBar.DesiredSize.Height : toolBar.DesiredSize.Width); 396toolBarTrayDesiredSize.Width = Math.Max(toolBarTrayDesiredSize.Width, bandLength); 401toolBarTrayDesiredSize.Height = Math.Max(toolBarTrayDesiredSize.Height, bandLength); 792currentToolBar.Width = Math.Max(currentToolBar.MinLength, currentToolBar.RenderSize.Width - toolBarOffset + position); 794currentToolBar.Height = Math.Max(currentToolBar.MinLength, currentToolBar.RenderSize.Height - toolBarOffset + position);
System\Windows\Controls\VirtualizedCellInfoCollection.cs (12)
609int left = Math.Max(Left, region.Left); 610int top = Math.Max(Top, region.Top); 611int right = Math.Min(Right, region.Right); 612int bottom = Math.Min(Bottom, region.Bottom); 682Left = Math.Min(Left, region.Left); 683Top = Math.Min(Top, region.Top); 684Right = Math.Max(prevRight, region.Right); 685Bottom = Math.Max(prevBottom, region.Bottom); 725int top = Math.Max(Top, region.Top); 726int bottom = Math.Min(Bottom, region.Bottom); 733int top = Math.Max(Top, region.Top); 734int bottom = Math.Min(Bottom, region.Bottom);
System\Windows\Controls\VirtualizingStackPanel.cs (185)
511double delta = Math.Abs(scrollX - oldViewportOffset.X); 524_scrollData._offset.X = Math.Floor(_scrollData._offset.X); 525_scrollData._computedOffset.X = Math.Floor(_scrollData._computedOffset.X); 639double delta = Math.Abs(scrollY - oldViewportOffset.Y); 652_scrollData._offset.Y = Math.Floor(_scrollData._offset.Y); 653_scrollData._computedOffset.Y = Math.Floor(_scrollData._computedOffset.Y); 2331double factor = Math.Min(1.0, isHorizontal ? viewport.Width / extendedViewport.Width : viewport.Height / extendedViewport.Height); 2332int calcItemsInViewportCount = (int)Math.Ceiling(factor * _itemsInExtendedViewportCount); 2333excludeCount = Math.Max(excludeCount, 2627double spanBeforeViewport = Math.Max(isHorizontal ? viewport.X : viewport.Y, 0.0); 2684_firstItemInExtendedViewportIndex = Math.Max(_firstItemInExtendedViewportIndex - 1, 0); 2686_firstItemInExtendedViewportChildIndex = Math.Max(_firstItemInExtendedViewportChildIndex, 0); 3384arrangeLength = Math.Max(isHorizontal ? arrangeSize.Height : arrangeSize.Width, arrangeLength); 4762pixelSizeBeforeViewport = Math.Max(pixelSizeBeforeViewport, Math.Abs(_viewport.X - _extendedViewport.X)); 4766logicalSizeBeforeViewport = Math.Max(logicalSizeBeforeViewport, Math.Abs(_viewport.X - _extendedViewport.X)); 4798extendedViewport.Width = Math.Max(extendedViewport.Width + extendedViewport.X, 0.0); 4809extendedViewport.Width = Math.Max(_scrollData._extent.Width - extendedViewport.X, 0.0); 4838extendedViewport.Width = Math.Max(extendedViewport.Width / approxSizeOfLogicalUnit + extendedViewport.X, 0.0) * approxSizeOfLogicalUnit; 4849extendedViewport.Width = Math.Max(_scrollData._extent.Width - extendedViewport.X, 0.0) * approxSizeOfLogicalUnit; 4878pixelSizeBeforeViewport = Math.Max(pixelSizeBeforeViewport, Math.Abs(_viewport.Y - _extendedViewport.Y)); 4882logicalSizeBeforeViewport = Math.Max(logicalSizeBeforeViewport, Math.Abs(_viewport.Y - _extendedViewport.Y)); 4914extendedViewport.Height = Math.Max(extendedViewport.Height + extendedViewport.Y, 0.0); 4925extendedViewport.Height = Math.Max(_scrollData._extent.Height - extendedViewport.Y, 0.0); 4954extendedViewport.Height = Math.Max(extendedViewport.Height / approxSizeOfLogicalUnit + extendedViewport.Y, 0.0) * approxSizeOfLogicalUnit; 4965extendedViewport.Height = Math.Max(_scrollData._extent.Height - extendedViewport.Y, 0.0) * approxSizeOfLogicalUnit; 4977double factor = Math.Max(1.0, isHorizontal ? extendedViewport.Width / viewport.Width : extendedViewport.Height / viewport.Height); 4978int calcItemsInExtendedViewportCount = (int)Math.Ceiling(factor * _actualItemsInExtendedViewportCount); 4979itemsInExtendedViewportCount = Math.Max(calcItemsInExtendedViewportCount, itemsInExtendedViewportCount); 5090viewport.Width = Math.Max(viewport.Width - sizeAfterStartViewportEdge, 0); 5094cacheBeforeSize = Math.Max(cacheBeforeSize - sizeBeforeStartViewportEdge, 0); 5098cacheBeforeSize = Math.Max(cacheBeforeSize - Math.Floor(logicalSize.Width * sizeBeforeStartViewportEdge / pixelSize.Width), 0); 5125viewport.Width = Math.Max(0, parentViewport.Width - pixelSize.Width); 5140cacheAfterSize = Math.Max(cacheAfterSize - sizeAfterEndViewportEdge, 0); 5144cacheAfterSize = Math.Max(cacheAfterSize - Math.Floor(logicalSize.Width * sizeAfterEndViewportEdge / pixelSize.Width), 0); 5156cacheAfterSize = Math.Max(cacheAfterSize - pixelSize.Width, 0); 5160cacheAfterSize = Math.Max(cacheAfterSize - logicalSize.Width, 0); 5189viewport.Height = Math.Max(viewport.Height - sizeAfterStartViewportEdge, 0); 5193cacheBeforeSize = Math.Max(cacheBeforeSize - sizeBeforeStartViewportEdge, 0); 5197cacheBeforeSize = Math.Max(cacheBeforeSize - Math.Floor(logicalSize.Height * sizeBeforeStartViewportEdge / pixelSize.Height), 0); 5224viewport.Height = Math.Max(0, parentViewport.Height - pixelSize.Height); 5239cacheAfterSize = Math.Max(cacheAfterSize - sizeAfterEndViewportEdge, 0); 5243cacheAfterSize = Math.Max(cacheAfterSize - Math.Floor(logicalSize.Height * sizeAfterEndViewportEdge / pixelSize.Height), 0); 5255cacheAfterSize = Math.Max(cacheAfterSize - pixelSize.Height, 0); 5259cacheAfterSize = Math.Max(cacheAfterSize - logicalSize.Height, 0); 5324cacheBeforeSize = Math.Max(0, cacheBeforeSize - parentViewport.X); 5329viewport.Width = Math.Max(0, viewport.Width + viewport.X); 5349cacheBeforeSize = Math.Max(0, cacheBeforeSize - inset.Right); 5353cacheBeforeSize = Math.Max(0, cacheBeforeSize - 1); 5368viewport.Width = Math.Max(0, viewport.Width - inset.Left); 5379cacheAfterSize = Math.Max(0, cacheAfterSize - (inset.Left - viewport.Width)); 5396cacheAfterSize = Math.Max(0, cacheAfterSize - inset.Left); 5400cacheAfterSize = Math.Max(0, cacheAfterSize - 1); 5427cacheBeforeSize = Math.Max(0, cacheBeforeSize - parentViewport.Y); 5432viewport.Height = Math.Max(0, viewport.Height + viewport.Y); 5452cacheBeforeSize = Math.Max(0, cacheBeforeSize - inset.Bottom); 5456cacheBeforeSize = Math.Max(0, cacheBeforeSize - 1); 5471viewport.Height = Math.Max(0, viewport.Height - inset.Top); 5482cacheAfterSize = Math.Max(0, cacheAfterSize - (inset.Top - viewport.Height)); 5499cacheAfterSize = Math.Max(0, cacheAfterSize - inset.Top); 5503cacheAfterSize = Math.Max(0, cacheAfterSize - 1); 5559double spanBeforeViewport = Math.Max(isHorizontal ? viewport.X : viewport.Y, 0.0); 5571firstItemInViewportIndex = (int)Math.Floor(spanBeforeViewport / childSize); 6547double eps = (Math.Abs(value1) + Math.Abs(value2)) * Tolerance; 6728childViewport.X = Math.Min(childViewport.X, 0) - 6731childViewport.Width = Math.Max(childViewport.Width - stackPixelSizeInViewport.Width, 0.0); 6736childViewport.Width = Math.Max(childViewport.Width - stackPixelSizeInViewport.Width, 0.0); 6744Math.Max(parentCacheSize.CacheBeforeViewport - stackLogicalSizeInCacheBeforeViewport.Width, 0.0), 6747Math.Max(parentCacheSize.CacheAfterViewport - stackLogicalSizeInCacheAfterViewport.Width, 0.0)); 6755Math.Max(parentCacheSize.CacheBeforeViewport - stackPixelSizeInCacheBeforeViewport.Width, 0.0), 6758Math.Max(parentCacheSize.CacheAfterViewport - stackPixelSizeInCacheAfterViewport.Width, 0.0)); 6773childViewport.Y = Math.Min(childViewport.Y, 0) - 6777childViewport.Height = Math.Max(childViewport.Height - stackPixelSizeInViewport.Height, 0.0); 6782childViewport.Height = Math.Max(childViewport.Height - stackPixelSizeInViewport.Height, 0.0); 6790Math.Max(parentCacheSize.CacheBeforeViewport - stackLogicalSizeInCacheBeforeViewport.Height, 0.0), 6793Math.Max(parentCacheSize.CacheAfterViewport - stackLogicalSizeInCacheAfterViewport.Height, 0.0)); 6801Math.Max(parentCacheSize.CacheBeforeViewport - stackPixelSizeInCacheBeforeViewport.Height, 0.0), 6804Math.Max(parentCacheSize.CacheAfterViewport - stackPixelSizeInCacheAfterViewport.Height, 0.0)); 6909childLogicalSize.Width = Math.Max(itemDesiredSizes.LogicalSize.Width, logicalHeaderSize.Width); 6914childLogicalSize.Height = Math.Max(itemDesiredSizes.LogicalSize.Height, logicalHeaderSize.Height); 7113Size frontPixelSize = isHorizontal ? new Size(Math.Max(inset.Left,0), childDesiredSize.Height) 7114: new Size(childDesiredSize.Width, Math.Max(inset.Top, 0)); 7127Size backPixelSize = isHorizontal ? new Size(Math.Max(inset.Right,0), childDesiredSize.Height) 7128: new Size(childDesiredSize.Width, Math.Max(inset.Bottom,0)); 7141adjustedChildViewport.Width = Math.Max(0, adjustedChildViewport.Width - childPixelSizeInViewport.Width); 7147adjustedChildViewport.Height = Math.Max(0, adjustedChildViewport.Height - childPixelSizeInViewport.Height); 7232pixelSizeBeforeViewport = DoubleUtil.LessThan(childViewport.X, childPixelSize.Width) ? Math.Max(childViewport.X, 0.0) : childPixelSize.Width; 7233pixelSizeInViewport = Math.Min(childViewport.Width, childPixelSize.Width - pixelSizeBeforeViewport); 7234pixelSizeAfterViewport = 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 7279logicalSizeBeforeViewport = Math.Floor(childLogicalSize.Width * pixelSizeBeforeViewport / childPixelSize.Width); 7280logicalSizeAfterViewport = Math.Floor(childLogicalSize.Width * pixelSizeAfterViewport / childPixelSize.Width); 7288double childPixelHeightInViewport = Math.Min(childViewport.Height, childPixelSize.Height - Math.Max(childViewport.Y, 0.0)); 7291childPixelSizeInViewport.Height = Math.Max(childPixelSizeInViewport.Height, childPixelHeightInViewport); 7293childPixelSizeInCacheBeforeViewport.Height = Math.Max(childPixelSizeInCacheBeforeViewport.Height, childPixelHeightInViewport); 7295childPixelSizeInCacheAfterViewport.Height = Math.Max(childPixelSizeInCacheAfterViewport.Height, childPixelHeightInViewport); 7298childLogicalSizeInViewport.Height = Math.Max(childLogicalSizeInViewport.Height, childLogicalSize.Height); 7300childLogicalSizeInCacheBeforeViewport.Height = Math.Max(childLogicalSizeInCacheBeforeViewport.Height, childLogicalSize.Height); 7302childLogicalSizeInCacheAfterViewport.Height = Math.Max(childLogicalSizeInCacheAfterViewport.Height, childLogicalSize.Height); 7324pixelSizeBeforeViewport = DoubleUtil.LessThan(childViewport.Y, childPixelSize.Height) ? Math.Max(childViewport.Y, 0.0) : childPixelSize.Height; 7325pixelSizeInViewport = Math.Min(childViewport.Height, childPixelSize.Height - pixelSizeBeforeViewport); 7326pixelSizeAfterViewport = 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 7371logicalSizeBeforeViewport = Math.Floor(childLogicalSize.Height * pixelSizeBeforeViewport / childPixelSize.Height); 7372logicalSizeAfterViewport = Math.Floor(childLogicalSize.Height * pixelSizeAfterViewport / childPixelSize.Height); 7380double childPixelWidthInViewport = Math.Min(childViewport.Width, childPixelSize.Width - Math.Max(childViewport.X, 0.0)); 7383childPixelSizeInViewport.Width = Math.Max(childPixelSizeInViewport.Width, childPixelWidthInViewport); 7385childPixelSizeInCacheBeforeViewport.Width = Math.Max(childPixelSizeInCacheBeforeViewport.Width, childPixelWidthInViewport); 7387childPixelSizeInCacheAfterViewport.Width = Math.Max(childPixelSizeInCacheAfterViewport.Width, childPixelWidthInViewport); 7390childLogicalSizeInViewport.Width = Math.Max(childLogicalSizeInViewport.Width, childLogicalSize.Width); 7392childLogicalSizeInCacheBeforeViewport.Width = Math.Max(childLogicalSizeInCacheBeforeViewport.Width, childLogicalSize.Width); 7394childLogicalSizeInCacheAfterViewport.Width = Math.Max(childLogicalSizeInCacheAfterViewport.Width, childLogicalSize.Width); 7437sz1.Height = Math.Max(sz1.Height, sz2.Height); 7442sz1.Width = Math.Max(sz1.Width, sz2.Width); 7492childSize = new Size(Math.Max(headerDesiredSizes.PixelSize.Width, itemDesiredSizes.PixelSize.Width), 7497childSize = new Size(Math.Max(headerDesiredSizes.LogicalSize.Width, itemDesiredSizes.LogicalSize.Width), 7581uniformOrAverageContainerSize = Math.Round(sumOfContainerSizes / numContainerSizes); 7665Math.Max(1, itemDesiredSizes.LogicalSize.Height)) 7666: new Size(Math.Max(1, itemDesiredSizes.LogicalSize.Width), 7807Math.Max(uniformOrAverageContainerPixelSize, dpiScale), // don't round down to 0 7817uniformOrAverageContainerSize = Math.Round(sumOfContainerSizes / numContainerSizes); 8480rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height); 8505previousChildSize.Width = Math.Max(previousChildSize.Width, pixelHeaderSize.Width); 8512rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width); 8537previousChildSize.Height = Math.Max(previousChildSize.Height, pixelHeaderSize.Height); 8567rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height); 8573rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width); 8611rcChild.Height = Math.Max(arrangeLength, childDesiredSize.Height); 8664rcChild.Width = Math.Max(arrangeLength, childDesiredSize.Width); 9539return Math.Max(0, _firstItemInExtendedViewportIndex); 9547return Math.Min(ItemCount, _firstItemInExtendedViewportIndex + _actualItemsInExtendedViewportCount); 9665_scrollData._maxDesiredSize.Height = Math.Max(_scrollData._maxDesiredSize.Height, stackPixelSize.Height); 9692_scrollData._maxDesiredSize.Width = Math.Max(_scrollData._maxDesiredSize.Width, stackPixelSize.Width); 9718Math.Min(stackPixelSize.Width, constraint.Width) : constraint.Width; 9723Math.Min(stackPixelSize.Height, constraint.Height) : constraint.Height; 9733Debug.Assert(DoubleUtil.AreClose(viewportSize.Width - Math.Floor(viewportSize.Width), 0.0), "The viewport size must not contain fractional values when in item scrolling mode."); 9734Debug.Assert(DoubleUtil.AreClose(extentSize.Width - Math.Floor(extentSize.Width), 0.0), "The extent size must not contain fractional values when in item scrolling mode."); 9738Debug.Assert(DoubleUtil.AreClose(viewportSize.Height - Math.Floor(viewportSize.Height), 0.0), "The viewport size must not contain fractional values when in item scrolling mode."); 9739Debug.Assert(DoubleUtil.AreClose(extentSize.Height - Math.Floor(extentSize.Height), 0.0), "The extent size must not contain fractional values when in item scrolling mode."); 9992double proposedViewportSize = Math.Floor(viewport.Width / approxSizeOfLogicalUnit); 10085if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.X)/extentSize.Width, Math.Floor(_scrollData._offset.X)/_scrollData._extent.Width)) 10088viewportOffset.X = Math.Floor((extentSize.Width * Math.Floor(_scrollData._offset.X)) / _scrollData._extent.Width); 10209double proposedViewportSize = Math.Floor(viewport.Height / approxSizeOfLogicalUnit); 10302if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.Y)/extentSize.Height, Math.Floor(_scrollData._offset.Y)/_scrollData._extent.Height)) 10305viewportOffset.Y = Math.Floor((extentSize.Height * Math.Floor(_scrollData._offset.Y)) / _scrollData._extent.Height); 10517_scrollData._maxDesiredSize.Height = Math.Max(_scrollData._maxDesiredSize.Height, stackPixelSize.Height); 10544_scrollData._maxDesiredSize.Width = Math.Max(_scrollData._maxDesiredSize.Width, stackPixelSize.Width); 10570Math.Min(stackPixelSize.Width, constraint.Width) : constraint.Width; 10575Math.Min(stackPixelSize.Height, constraint.Height) : constraint.Height; 10585Debug.Assert(DoubleUtil.AreClose(viewportSize.Width - Math.Floor(viewportSize.Width), 0.0), "The viewport size must not contain fractional values when in item scrolling mode."); 10586Debug.Assert(DoubleUtil.AreClose(extentSize.Width - Math.Floor(extentSize.Width), 0.0), "The extent size must not contain fractional values when in item scrolling mode."); 10590Debug.Assert(DoubleUtil.AreClose(viewportSize.Height - Math.Floor(viewportSize.Height), 0.0), "The viewport size must not contain fractional values when in item scrolling mode."); 10591Debug.Assert(DoubleUtil.AreClose(extentSize.Height - Math.Floor(extentSize.Height), 0.0), "The extent size must not contain fractional values when in item scrolling mode."); 10671lastPageSafeOffset = lastPageSafeOffset.HasValue ? Math.Min(computedViewportOffset.X, (double)lastPageSafeOffset) : computedViewportOffset.X; 10674double proposedViewportSize = Math.Floor(viewport.Width / approxSizeOfLogicalUnit); 10756if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.X)/extentSize.Width, Math.Floor(_scrollData._offset.X)/_scrollData._extent.Width)) 10759viewportOffset.X = Math.Floor((extentSize.Width * Math.Floor(_scrollData._offset.X)) / _scrollData._extent.Width); 10802lastPageSafeOffset = lastPageSafeOffset.HasValue ? Math.Min(computedViewportOffset.Y, (double)lastPageSafeOffset) : computedViewportOffset.Y; 10805double proposedViewportSize = Math.Floor(viewport.Height / approxSizeOfLogicalUnit); 10887if (!LayoutDoubleUtil.AreClose(Math.Floor(computedViewportOffset.Y)/extentSize.Height, Math.Floor(_scrollData._offset.Y)/_scrollData._extent.Height)) 10890viewportOffset.Y = Math.Floor((extentSize.Height * Math.Floor(_scrollData._offset.Y)) / _scrollData._extent.Height); 11188double visibleStart = Math.Max(start, 0); 11189double visibleEnd = Math.Max(Math.Min(end, viewportSize), visibleStart); 11234else if (childIndex > firstChildInView + Math.Max(viewportSize - 1, 0)) 11280maxChildLength = Math.Max(maxChildLength, childSize.Height); 11284maxChildLength = Math.Max(maxChildLength, childSize.Width); 11876else if (DoubleUtil.GreaterThan(Math.Abs(newOffset - oldOffset), _viewport.Width)) 11892else if (DoubleUtil.GreaterThan(Math.Abs(newOffset - oldOffset), _viewport.Height))
System\Windows\Controls\WrapPanel.cs (5)
243panelSize.U = Math.Max(curLineSize.U, panelSize.U); 249panelSize.U = Math.Max(sz.U, panelSize.U); 257curLineSize.V = Math.Max(sz.V, curLineSize.V); 262panelSize.U = Math.Max(curLineSize.U, panelSize.U); 317curLineSize.V = Math.Max(sz.V, curLineSize.V);
System\Windows\Documents\Block.cs (2)
487double maxLineHeight = Math.Min(1000000, PTS.MaxFontSize); 531double maxThickness = Math.Min(1000000, PTS.MaxPageSize);
System\windows\Documents\CaretElement.cs (6)
407deltaToScroll = Math.Abs(targetPoint.Y); 408scroller.ScrollToVerticalOffset(Math.Max(0, scroller.VerticalOffset - deltaToScroll - scrollerHeight / 4)); 414scroller.ScrollToVerticalOffset(Math.Min(scroller.ExtentHeight, scroller.VerticalOffset + deltaToScroll + scrollerHeight / 4)); 424deltaToScroll = Math.Abs(targetPoint.X); 425scroller.ScrollToHorizontalOffset(Math.Max(0, scroller.HorizontalOffset - deltaToScroll - scrollerWidth / 4)); 431scroller.ScrollToHorizontalOffset(Math.Min(scroller.ExtentWidth, scroller.HorizontalOffset + deltaToScroll + scrollerWidth / 4));
System\Windows\Documents\DocumentSequenceTextPointer.cs (1)
1033distance = Math.Abs(distance);
System\Windows\Documents\Figure.cs (1)
298double maxOffset = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\FixedPageStructure.cs (4)
132line = Math.Max(0, Math.Min(line, _lineResults.Length - 1)); 157double absVerDistance = Math.Max(0, (pt.Y > lineResult.LayoutBox.Y) ? (pt.Y - lineResult.LayoutBox.Bottom) : (lineResult.LayoutBox.Y - pt.Y)); 158double absHorDistance = Math.Max(0, (pt.X > lineResult.LayoutBox.X) ? (pt.X - lineResult.LayoutBox.Right) : (lineResult.LayoutBox.X - pt.X));
System\Windows\Documents\FixedSOMPageConstructor.cs (5)
553if (Math.Abs(textRunRect.Left - fixedBlockRect.Left) <= textRun.DefaultCharWidth || 554Math.Abs(textRunRect.Right - fixedBlockRect.Right) <= textRun.DefaultCharWidth) 1026if (Math.Abs(t.BoundingRect.Left - row.BoundingRect.Left) < fudge && 1027Math.Abs(t.BoundingRect.Right - row.BoundingRect.Right) < fudge && 1028Math.Abs(t.BoundingRect.Bottom - row.BoundingRect.Top) < fudge)
System\Windows\Documents\FixedSOMSemanticBox.cs (1)
214double overlap = Math.Abs(thisRectRefX - otherRectRefX);
System\Windows\Documents\FixedSOMTextRun.cs (2)
137double yScale = Math.Sqrt(mat.M12*mat.M12 + mat.M22*mat.M22); 138double xScale = Math.Sqrt(mat.M11 * mat.M11 + mat.M21 * mat.M21);
System\Windows\Documents\FixedTextBuilder.cs (2)
865double xDistance = Math.Abs(currentPt.X - prevPt.X); 866double maxHeight = Math.Max(box1.Height, box2.Height);
System\Windows\Documents\FixedTextView.cs (2)
840double horizontalDistance = Math.Max(0, (transformedPt.X > alignmentRect.X) ? (transformedPt.X - alignmentRect.Right) : (alignmentRect.X - transformedPt.X)); 841double verticalDistance = Math.Max(0, (transformedPt.Y > alignmentRect.Y) ? (transformedPt.Y - alignmentRect.Bottom) : (alignmentRect.Y - transformedPt.Y));
System\Windows\Documents\Floater.cs (1)
132double maxWidth = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\FlowDocument.cs (5)
1529double maxSize = Math.Min(1000000, PTS.MaxPageSize); 1544double maxSize = Math.Min(1000000, PTS.MaxPageSize); 1559double maxSize = Math.Min(1000000, PTS.MaxPageSize); 1580double maxRuleWidth = Math.Min(1000000, PTS.MaxPageSize); 1591double maxGap = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\FlowPosition.cs (2)
214maxLength = Math.Min(maxLength, remainingLength); 311distance = Math.Abs(distance);
System\Windows\Documents\Glyphs.cs (3)
144Math.Max(0, designRect.Right), 145Math.Max(0, designRect.Bottom) 521estimatedNumberOfGlyphs = Math.Max(estimatedNumberOfGlyphs, glyphsProp.Length / 5);
System\Windows\Documents\ImmComposition.cs (5)
666milPointTopLeft = new Point(Math.Min(rectStart.Left, rectEnd.Left), Math.Min(rectStart.Top, rectEnd.Top)); 667milPointBottomRight = new Point(Math.Max(rectStart.Left, rectEnd.Left), Math.Max(rectStart.Bottom, rectEnd.Bottom)); 1120_caretOffset = Math.Min(_caretOffset, text.Length);
System\Windows\Documents\List.cs (1)
327double maxOffset = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\Paragraph.cs (1)
303double maxIndent = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\RangeContentEnumerator.cs (1)
304newBuffer = new char[Math.Max(2*_buffer.Length, size)];
System\Windows\Documents\Speller.cs (7)
998int timeOutOffset = Math.Min(data.TextMap.ContentEndOffset, sentenceEndOffset); 1182sTextRange = (SpellerInteropBase.ITextRange)segments[Math.Max(i, 0)]; 1185contextOffset = Math.Min(sTextRange.Start, contentOffset); 1190sTextRange = (SpellerInteropBase.ITextRange)segments[Math.Min(i, segments.Count-1)]; 1193contextOffset = Math.Max(sTextRange.Start + sTextRange.Length, contentOffset); 1689runCount = Math.Min(runCount, _text.Length - _textLength); 1690runCount = Math.Min(runCount, position.GetOffsetToPosition(contextEnd));
System\Windows\Documents\Table.cs (2)
198get { return Math.Max(CellSpacing, 0); } 378double maxSpacing = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\TableColumn.cs (1)
197double maxPixel = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\Documents\TableRowGroup.cs (1)
211_columnCount = Math.Max(_columnCount, Rows[i].ColumnCount);
System\Windows\Documents\TextContainerChangedEventArgs.cs (3)
237change.RemovedLength += Math.Max(0, length - change.AddedLength); 238change.AddedLength = Math.Max(0, change.AddedLength - length); 400int cancelledCount = Math.Min(overlap, newChange.RemovedLength);
System\windows\Documents\TextEditor.cs (2)
518_mouseSelectionState.Timer.Interval = TimeSpan.FromMilliseconds(Math.Max(SystemParameters.MenuShowDelay, 200)); 1185int extraCharsAllowed = Math.Max(0, this.MaxLength - currentLength);
System\Windows\Documents\TextElement.cs (1)
1605double maxFontSize = Math.Min(1000000, PTS.MaxFontSize);
System\Windows\Documents\TextFindEngine.cs (4)
208int textBlockLength = Math.Max(TextBlockLength, findPattern.Length * 2 * 2); 663runCount = Math.Min(runCount, findText.Length - findTextLength); 667runCount = Math.Min(runCount, navigator.GetOffsetToPosition(endPosition)); 677runCount = Math.Min(runCount, startPosition.GetOffsetToPosition(navigator));
System\Windows\Documents\TextPointer.cs (1)
1790finalCount += Math.Min(count - finalCount, textNode.SymbolCount - skipCount);
System\Windows\Documents\TextPointerBase.cs (5)
102maxCount = Math.Min(count, thisPointer.GetOffsetToPosition(limit)); 106maxCount = Math.Min(count, limit.GetOffsetToPosition(thisPointer)); 108maxCount = Math.Min(count, maxCount); 1424runLength = Math.Min(navigator.GetTextRunLength(LogicalDirection.Backward), SelectionWordBreaker.MinContextLength - preceedingCount); 1443runLength = Math.Min(navigator.GetTextRunLength(LogicalDirection.Forward), SelectionWordBreaker.MinContextLength - followingCount);
System\Windows\Documents\TextRangeEdit.cs (4)
2346new DoublePropertyRange (Paragraph.TextIndentProperty, -Math.Min(1000000, PTS.MaxPageSize), Math.Min(1000000, PTS.MaxPageSize)) 2368double retValue = Math.Max(_lowerBound, value); 2369retValue = Math.Min(retValue, _upperBound);
System\Windows\Documents\TextRangeEditTables.cs (10)
333int firstRowIndex = Math.Min(anchorCell.Row.Index, movingCell.Row.Index); 334int lastRowIndex = Math.Max(anchorCell.Row.Index + anchorCell.RowSpan - 1, movingCell.Row.Index + movingCell.RowSpan - 1); 335int firstColumnIndex = Math.Min(anchorCell.ColumnIndex, movingCell.ColumnIndex); 336int lastColumnIndex = Math.Max(anchorCell.ColumnIndex + anchorCell.ColumnSpan - 1, movingCell.ColumnIndex + movingCell.ColumnSpan - 1); 1426int cCols = Math.Abs(columnCount); 1708_dxr = Math.Max(_dxr, 0.0); 1731xPosAdorner = Math.Max(xPosAdorner, _columnRect.Left - this.LeftDragMax); 1732xPosAdorner = Math.Min(xPosAdorner, _columnRect.Right + this.RightDragMax); 1743dx = Math.Max(dx, - this.LeftDragMax); 1744dx = Math.Min(dx, this.RightDragMax);
System\windows\Documents\TextSelection.cs (2)
2248caretRectangle.Y += caretRectangle.Height - Math.Abs(bottom.Y - top.Y); 2249caretRectangle.Height = Math.Abs(bottom.Y - top.Y);
System\Windows\Documents\TextStore.cs (12)
989milPointTopLeft = new Point(Math.Min(rectPrev.Left, rectCur.Left), Math.Min(rectPrev.Top, rectCur.Top)); 990milPointBottomRight = new Point(Math.Max(rectPrev.Left, rectCur.Left), Math.Max(rectPrev.Bottom, rectCur.Bottom)); 2459runCount = TextPointerBase.GetTextWithLimit(navigator, LogicalDirection.Forward, text, charsCopied, Math.Min(cchReq, text.Length - charsCopied), limit); 2860double radSin = Math.Asin(tf.M12 / Math.Sqrt((tf.M11 * tf.M11) + (tf.M12 * tf.M12))); 2861double radCos = Math.Acos(tf.M11 / Math.Sqrt((tf.M11 * tf.M11) + (tf.M12 * tf.M12))); 2863double angleCos = Math.Round((radCos * 180) / Math.PI, 0); 3826int extraCharsAllowed = Math.Max(0, this.TextEditor.MaxLength - currentLength);
System\Windows\Documents\TextTreeText.cs (4)
102firstCount = Math.Min(count, firstBlock.Count - firstBlockLocalOffset); 299count = Math.Min(rightBlock.FreeCapacity, length - textOffset); 341count = Math.Min(neighborBlock.FreeCapacity, textEndOffset - textOffset); 355count = Math.Min(rightBlock.FreeCapacity, textEndOffset - textOffset);
System\Windows\Documents\TextTreeTextBlock.cs (4)
94newText = new char[Math.Min(this.Count + count, MaxBlockSize)]; 109count = Math.Min(count, _gapSize); 248copyCount = Math.Min(count, _gapOffset - logicalOffset); 263copyCount = Math.Min(count, _text.Length - logicalOffset);
System\Windows\Documents\Tracing\SpellerCOMActionTraceLogger.cs (3)
196(long)Math.Floor(1.0d * _instanceInfo.CumulativeCallTime100Ns[_action] / _instanceInfo.NumCallsMeasured[_action]); 217CallTimeForCOMCallMs = (long)Math.Floor(ticks * 1.0d / 10000), 218RunningAverageCallTimeForCOMCallsMs = (long)Math.Floor(runningAverage * 1.0d / 10000)
System\Windows\Documents\WinRTSpellerInteropExtensions.cs (1)
173int altFormsCount = Math.Min(missingFragmentText.Length, AlternateFormsMaximumCount);
System\Windows\Documents\XamlToRtfWriter.cs (2)
1731tableWidth = Math.Max(tableWidth, lastCellX); 2892formatState.FontSize = (long)Math.Round(fs);
System\Windows\FigureLength.cs (1)
100double maxPixel = Math.Min(1000000, PTS.MaxPageSize);
System\Windows\FrameworkElement.cs (59)
4055maxHeight = Math.Max(Math.Min(height, maxHeight), minHeight); 4058minHeight = Math.Max(Math.Min(maxHeight, height), minHeight); 4065maxWidth = Math.Max(Math.Min(width, maxWidth), minWidth); 4068minWidth = Math.Max(Math.Min(maxWidth, width), minWidth); 4170Double yCoverD = (yConstrInfinite ? Double.PositiveInfinity : Math.Abs(yConstr/d)); 4171Double xCoverA = (xConstrInfinite ? Double.PositiveInfinity : Math.Abs(xConstr/a)); 4191h = Math.Min(0.5*Math.Abs(xConstr/c), yCoverD); 4202w = Math.Min( 0.5*Math.Abs(yConstr/b), xCoverA); 4210Double yCoverB = Math.Abs(yConstr/b); 4211Double xCoverC = Math.Abs(xConstr/c); 4231h = Math.Min(0.5*Math.Abs(yConstr/d), xCoverC); 4242w = Math.Min( 0.5*Math.Abs(xConstr/a), yCoverB); 4248Double xCoverA = Math.Abs(xConstr / a); // w-intercept of x-constraint line. 4249Double xCoverC = Math.Abs(xConstr / c); // h-intercept of x-constraint line. 4251Double yCoverB = Math.Abs(yConstr / b); // w-intercept of y-constraint line. 4252Double yCoverD = Math.Abs(yConstr / d); // h-intercept of y-constraint line. 4259w = Math.Min(yCoverB, xCoverA) * 0.5; 4260h = Math.Min(xCoverC, yCoverD) * 0.5; 4277Double expandFactor = Math.Min(xConstr / childBoundsTr.Width, 4336Math.Max(availableSize.Width - marginWidth, 0), 4337Math.Max(availableSize.Height - marginHeight, 0)); 4385frameworkAvailableSize.Width = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth)); 4386frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight)); 4399Math.Max(desiredSize.Width, mm.minWidth), 4400Math.Max(desiredSize.Height, mm.minHeight)); 4466ltd.TransformedUnroundedDS = new Size(Math.Max(0, clippedDesiredWidth), Math.Max(0, clippedDesiredHeight)); 4513return new Size(Math.Max(0, clippedDesiredWidth), Math.Max(0, clippedDesiredHeight)); 4575arrangeSize.Width = Math.Max(0, arrangeSize.Width - marginWidth); 4576arrangeSize.Height = Math.Max(0, arrangeSize.Height - marginHeight); 4585transformedUnroundedDS.Width = Math.Max(0, transformedUnroundedDS.Width - marginWidth); 4586transformedUnroundedDS.Height = Math.Max(0, transformedUnroundedDS.Height- marginHeight); 4595unclippedDesiredSize = new Size(Math.Max(0, this.DesiredSize.Width - marginWidth), 4596Math.Max(0, this.DesiredSize.Height - marginHeight)); 4601unclippedDesiredSize.Width = Math.Max(transformedUnroundedDS.Width, unclippedDesiredSize.Width); 4602unclippedDesiredSize.Height = Math.Max(transformedUnroundedDS.Height, unclippedDesiredSize.Height); 4689double effectiveMaxWidth = Math.Max(unclippedDesiredSize.Width, mm.maxWidth); 4696double effectiveMaxHeight = Math.Max(unclippedDesiredSize.Height, mm.maxHeight); 4727Size clippedInkSize = new Size(Math.Min(innerInkSize.Width, mm.maxWidth), 4728Math.Min(innerInkSize.Height, mm.maxHeight)); 4760Size clientSize = new Size(Math.Max(0, finalRect.Width - marginWidth), 4761Math.Max(0, finalRect.Height - marginHeight)); 4910inkSize.Width = Math.Min(inkSize.Width, mm.maxWidth); 4911inkSize.Height = Math.Min(inkSize.Height, mm.maxHeight); 4928Size clippingSize = new Size(Math.Max(0, layoutSlotSize.Width - marginWidth), 4929Math.Max(0, layoutSlotSize.Height - marginHeight)); 5241inkSize.Width = Math.Min(inkSize.Width, mm.maxWidth); 5242inkSize.Height = Math.Min(inkSize.Height, mm.maxHeight);
System\Windows\Input\KeyboardNavigation.cs (9)
2508rect.Height = Math.Min(Math.Max(before, 0.0d), rect.Height); 2512double height = Math.Min(Math.Max(after, 0.0d), rect.Height); 2528return Math.Sqrt(deltaX * deltaX + deltaY * deltaY); 2659startRange = Math.Min(startRange, _horizontalBaseline); 2660endRange = Math.Max(endRange, _horizontalBaseline); 2680startRange = Math.Min(startRange, _verticalBaseline); 2681endRange = Math.Max(endRange, _verticalBaseline);
System\Windows\Interop\HwndHost.cs (2)
701desiredSize.Width = Math.Min(_desiredSize.Width, constraint.Width); 702desiredSize.Height = Math.Min(_desiredSize.Height, constraint.Height);
System\Windows\Markup\Baml2006\SharedStream.cs (2)
149long end = Math.Min(_position + 1, _length); 174long end = Math.Min(_position + count, _length);
System\Windows\Markup\BamlRecordReader.cs (1)
1743defKeyList = new ArrayList(Math.Max (5, (int)(bamlRecord.ContentSize/400)));
System\Windows\Shapes\Ellipse.cs (4)
89width = Math.Min(width, height); 93width = Math.Max(width, height); 116Math.Max(0, finalSize.Width - penThickness), // Width 117Math.Max(0, finalSize.Height - penThickness)); // Height
System\Windows\Shapes\Rectangle.cs (4)
142width = Math.Min(width, height); 146width = Math.Max(width, height); 170Math.Max(0, finalSize.Width - penThickness), // Width 171Math.Max(0, finalSize.Height - penThickness)); // Height
System\Windows\Shapes\Shape.cs (6)
465return Math.Abs(StrokeThickness); 481thickness = Math.Abs(strokeThickness); 582xScale = Math.Max(availableSize.Width - strokeThickness, 0); 583yScale = Math.Max(availableSize.Height - strokeThickness, 0); 710return new Size(Math.Max(bounds.Right, 0), 711Math.Max(bounds.Bottom, 0));
System\Windows\Shell\TaskbarItemInfo.cs (2)
106progressValue = Math.Max(progressValue, 0); 107progressValue = Math.Min(1, progressValue);
System\Windows\Shell\WindowChromeWorker.cs (23)
815double shortestDimension = Math.Min(windowSize.Width, windowSize.Height); 818topLeftRadius = Math.Min(topLeftRadius, shortestDimension / 2); 834topRightRadius = Math.Min(topRightRadius, shortestDimension / 2); 842bottomLeftRadius = Math.Min(bottomLeftRadius, shortestDimension / 2); 850bottomRightRadius = Math.Min(bottomRightRadius, shortestDimension / 2); 877(int)Math.Floor(region.Left), 878(int)Math.Floor(region.Top), 879(int)Math.Ceiling(region.Right), 880(int)Math.Ceiling(region.Bottom)); 885(int)Math.Floor(region.Left), 886(int)Math.Floor(region.Top), 887(int)Math.Ceiling(region.Right) + 1, 888(int)Math.Ceiling(region.Bottom) + 1, 889(int)Math.Ceiling(radius), 890(int)Math.Ceiling(radius)); 978deviceGlassThickness.Top = Math.Max(0, deviceGlassThickness.Top); 983deviceGlassThickness.Left = Math.Max(0, deviceGlassThickness.Left); 988deviceGlassThickness.Bottom = Math.Max(0, deviceGlassThickness.Bottom); 993deviceGlassThickness.Right = Math.Max(0, deviceGlassThickness.Right); 1000cxLeftWidth = (int)Math.Ceiling(deviceGlassThickness.Left), 1001cxRightWidth = (int)Math.Ceiling(deviceGlassThickness.Right), 1002cyTopHeight = (int)Math.Ceiling(deviceGlassThickness.Top), 1003cyBottomHeight = (int)Math.Ceiling(deviceGlassThickness.Bottom),
System\Windows\Standard\NativeMethods.cs (4)
2024Left = Math.Min(rect1.Left, rect2.Left), 2025Top = Math.Min(rect1.Top, rect2.Top), 2026Right = Math.Max(rect1.Right, rect2.Right), 2027Bottom = Math.Max(rect1.Bottom, rect2.Bottom),
System\Windows\SystemFonts.cs (1)
1018return (double)(Math.Abs(height) * 96 / dpi);
System\Windows\SystemResources.cs (1)
2135List<object> deadKeys = new(Math.Min(_potentiallyDeadEntryCount, _entries.Count));
System\Windows\Window.cs (30)
1828frameworkAvailableSize.Width = Math.Max(mm.minWidth, Math.Min(frameworkAvailableSize.Width, mm.maxWidth)); 1829frameworkAvailableSize.Height = Math.Max(mm.minHeight, Math.Min(frameworkAvailableSize.Height, mm.maxHeight)); 1836Math.Max(desiredSize.Width, mm.minWidth), 1837Math.Max(desiredSize.Height, mm.minHeight)); 1858arrangeBounds.Width = Math.Max(mm.minWidth, Math.Min(arrangeBounds.Width, mm.maxWidth)); 1859arrangeBounds.Height = Math.Max(mm.minHeight, Math.Min(arrangeBounds.Height, mm.maxHeight)); 1893childArrangeBounds.Width = Math.Max(0.0, arrangeBounds.Width - frameSize.Width); 1894childArrangeBounds.Height = Math.Max(0.0, arrangeBounds.Height - frameSize.Height); 3429childConstraint.Width = ((constraint.Width == Double.PositiveInfinity) ? Double.PositiveInfinity : Math.Max(0.0, (constraint.Width - frameSize.Width))); 3430childConstraint.Height = ((constraint.Height == Double.PositiveInfinity) ? Double.PositiveInfinity : Math.Max(0.0, (constraint.Height - frameSize.Height))); 3474maxWidthDeviceUnits = Math.Max(_trackMaxWidthDeviceUnits, _windowMaxWidthDeviceUnits); 3475maxHeightDeviceUnits = Math.Max(_trackMaxHeightDeviceUnits, _windowMaxHeightDeviceUnits); 3484mm.minWidth = Math.Max(this.MinWidth, minSizeLogicalUnits.X); 3489mm.maxWidth = Math.Min(MinWidth, maxSizeLogicalUnits.X); 3495mm.maxWidth = Math.Min(MaxWidth, maxSizeLogicalUnits.X); 3506mm.minHeight = Math.Max(this.MinHeight, minSizeLogicalUnits.Y); 3511mm.maxHeight = Math.Min(this.MinHeight, maxSizeLogicalUnits.Y); 3517mm.maxHeight = Math.Min(MaxHeight, maxSizeLogicalUnits.Y); 3874leftDeviceUnits = Math.Min(leftDeviceUnits, workAreaRectDeviceUnits.right - currentSizeDeviceUnits.Width); 3875leftDeviceUnits = Math.Max(leftDeviceUnits, workAreaRectDeviceUnits.left); 3876topDeviceUnits = Math.Min(topDeviceUnits, workAreaRectDeviceUnits.bottom - currentSizeDeviceUnits.Height); 3877topDeviceUnits = Math.Max(topDeviceUnits, workAreaRectDeviceUnits.top); 4737_windowMaxWidthDeviceUnits = Math.Max(_windowMaxWidthDeviceUnits, windowSize.X); 4738_windowMaxHeightDeviceUnits = Math.Max(_windowMaxHeightDeviceUnits, windowSize.Y); 7635return new Size(Math.Max(0.0, pt.X), Math.Max(0.0, pt.Y));
PresentationFramework.Aero (21)
Microsoft\Windows\Themes\ButtonChrome.cs (4)
425desired = new Size(Math.Min(4.0, availableSize.Width), Math.Min(4.0, availableSize.Height)); 443childArrangeRect.Width = Math.Max(0d, finalSize.Width - 4.0); 444childArrangeRect.Height = Math.Max(0d, finalSize.Height - 4.0);
Microsoft\Windows\Themes\ListBoxChrome.cs (2)
249desired = new Size(Math.Min(borderX, availableSize.Width), Math.Min(borderY, availableSize.Height));
Microsoft\Windows\Themes\ScrollChrome.cs (5)
466bounds.Width = Math.Max(0.0, bounds.Width - 1.0); 537double height = Math.Min(7.0, bounds.Height); 560double width = Math.Min(7.0, bounds.Width); 724double widthScale = Math.Min(glyphWidth, bounds.Width) / glyphWidth; 725double heightScale = Math.Min(glyphHeight, bounds.Height) / glyphHeight;
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\DataGridHeaderBorder.cs (5)
193childWidth = Math.Max(0.0, childWidth - padding.Left - padding.Right); 198childHeight = Math.Max(0.0, childHeight - padding.Top - padding.Bottom); 233double childWidth = Math.Max(0.0, arrangeSize.Width - padding.Left - padding.Right); 234double childHeight = Math.Max(0.0, arrangeSize.Height - padding.Top - padding.Bottom); 300return Math.Max(0.0, d);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\SystemDropShadowChrome.cs (5)
112double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5); 113cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius); 114cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius); 115cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius); 116cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);
PresentationFramework.Aero2 (21)
Microsoft\Windows\Themes\ButtonChrome.cs (4)
425desired = new Size(Math.Min(4.0, availableSize.Width), Math.Min(4.0, availableSize.Height)); 443childArrangeRect.Width = Math.Max(0d, finalSize.Width - 4.0); 444childArrangeRect.Height = Math.Max(0d, finalSize.Height - 4.0);
Microsoft\Windows\Themes\ListBoxChrome.cs (2)
249desired = new Size(Math.Min(borderX, availableSize.Width), Math.Min(borderY, availableSize.Height));
Microsoft\Windows\Themes\ScrollChrome.cs (5)
466bounds.Width = Math.Max(0.0, bounds.Width - 1.0); 537double height = Math.Min(7.0, bounds.Height); 560double width = Math.Min(7.0, bounds.Width); 724double widthScale = Math.Min(glyphWidth, bounds.Width) / glyphWidth; 725double heightScale = Math.Min(glyphHeight, bounds.Height) / glyphHeight;
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\DataGridHeaderBorder.cs (5)
193childWidth = Math.Max(0.0, childWidth - padding.Left - padding.Right); 198childHeight = Math.Max(0.0, childHeight - padding.Top - padding.Bottom); 233double childWidth = Math.Max(0.0, arrangeSize.Width - padding.Left - padding.Right); 234double childHeight = Math.Max(0.0, arrangeSize.Height - padding.Top - padding.Bottom); 300return Math.Max(0.0, d);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\SystemDropShadowChrome.cs (5)
112double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5); 113cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius); 114cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius); 115cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius); 116cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);
PresentationFramework.AeroLite (14)
Microsoft\Windows\Themes\ScrollChrome.cs (2)
241double height = Math.Min(7.0, bounds.Height); 256double width = Math.Min(7.0, bounds.Width);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\DataGridHeaderBorder.cs (5)
193childWidth = Math.Max(0.0, childWidth - padding.Left - padding.Right); 198childHeight = Math.Max(0.0, childHeight - padding.Top - padding.Bottom); 233double childWidth = Math.Max(0.0, arrangeSize.Width - padding.Left - padding.Right); 234double childHeight = Math.Max(0.0, arrangeSize.Height - padding.Top - padding.Bottom); 300return Math.Max(0.0, d);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\ProgressBarBrushConverter.cs (2)
84int blocks = (int)Math.Ceiling(width / blockTotal); 159if (!isIndeterminate && remainder > 0.0 && Math.Abs(width - trackWidth) < 1.0e-5)
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\SystemDropShadowChrome.cs (5)
112double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5); 113cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius); 114cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius); 115cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius); 116cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);
PresentationFramework.Classic (23)
Microsoft\Windows\Themes\ClassicBorderDecorator.cs (11)
236float min = Math.Min(rgbColor.Red, Math.Min(rgbColor.Green, rgbColor.Blue)); 237float max = Math.Max(rgbColor.Red, Math.Max(rgbColor.Green, rgbColor.Blue)); 269saturation = Math.Max(0.0f, Math.Min(saturation, 1.0f)); 324float hue = (float)((hlsColor.Hue - Math.Floor(hlsColor.Hue)) * 6); 600Math.Max(0.0, rt.Width - thick.Left - thick.Right), 601Math.Max(0.0, rt.Height - thick.Top - thick.Bottom)); 689desired = new Size(Math.Min(borderSize.Width, availableSize.Width), Math.Min(borderSize.Height, availableSize.Height));
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\DataGridHeaderBorder.cs (5)
193childWidth = Math.Max(0.0, childWidth - padding.Left - padding.Right); 198childHeight = Math.Max(0.0, childHeight - padding.Top - padding.Bottom); 233double childWidth = Math.Max(0.0, arrangeSize.Width - padding.Left - padding.Right); 234double childHeight = Math.Max(0.0, arrangeSize.Height - padding.Top - padding.Bottom); 300return Math.Max(0.0, d);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\ProgressBarBrushConverter.cs (2)
84int blocks = (int)Math.Ceiling(width / blockTotal); 159if (!isIndeterminate && remainder > 0.0 && Math.Abs(width - trackWidth) < 1.0e-5)
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\SystemDropShadowChrome.cs (5)
112double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5); 113cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius); 114cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius); 115cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius); 116cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);
PresentationFramework.Luna (27)
Microsoft\Windows\Themes\ButtonChrome.cs (4)
346desired = new Size(Math.Min(sideThickness2, availableSize.Width), Math.Min(sideThickness2, availableSize.Height)); 364childArrangeRect.Width = Math.Max(0d, finalSize.Width - sideThickness2); 365childArrangeRect.Height = Math.Max(0d, finalSize.Height - sideThickness2);
Microsoft\Windows\Themes\ScrollChrome.cs (5)
306bounds.Width = Math.Max(0.0, bounds.Width - 1.0); 380double height = Math.Min(6.0, bounds.Height); 402double width = Math.Min(6.0, bounds.Width); 584double widthScale = Math.Min(glyphWidth, bounds.Width) / glyphWidth; 585double heightScale = Math.Min(glyphHeight, bounds.Height) / glyphHeight;
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\BulletChrome.cs (6)
190desired = new Size(Math.Min(11.0 + borderX, availableSize.Width), Math.Min(11.0 + borderY, availableSize.Height)); 213Math.Max(0, bounds.Width - thickness.Left - thickness.Right), 214Math.Max(0, bounds.Height - thickness.Top - thickness.Bottom)); 455Math.Max(0.0, rt.Width - thick.Left - thick.Right), 456Math.Max(0.0, rt.Height - thick.Top - thick.Bottom));
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\DataGridHeaderBorder.cs (5)
193childWidth = Math.Max(0.0, childWidth - padding.Left - padding.Right); 198childHeight = Math.Max(0.0, childHeight - padding.Top - padding.Bottom); 233double childWidth = Math.Max(0.0, arrangeSize.Width - padding.Left - padding.Right); 234double childHeight = Math.Max(0.0, arrangeSize.Height - padding.Top - padding.Bottom); 300return Math.Max(0.0, d);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\ProgressBarBrushConverter.cs (2)
84int blocks = (int)Math.Ceiling(width / blockTotal); 159if (!isIndeterminate && remainder > 0.0 && Math.Abs(width - trackWidth) < 1.0e-5)
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\SystemDropShadowChrome.cs (5)
112double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5); 113cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius); 114cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius); 115cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius); 116cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);
PresentationFramework.Royale (26)
Microsoft\Windows\Themes\ButtonChrome.cs (4)
304desired = new Size(Math.Min(sideThickness2, availableSize.Width), Math.Min(sideThickness2, availableSize.Height)); 322childArrangeRect.Width = Math.Max(0d, finalSize.Width - sideThickness2); 323childArrangeRect.Height = Math.Max(0d, finalSize.Height - sideThickness2);
Microsoft\Windows\Themes\ScrollChrome.cs (4)
340double height = Math.Min(6.0, bounds.Height); 362double width = Math.Min(6.0, bounds.Width); 544double widthScale = Math.Min(glyphWidth, bounds.Width) / glyphWidth; 545double heightScale = Math.Min(glyphHeight, bounds.Height) / glyphHeight;
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\BulletChrome.cs (6)
190desired = new Size(Math.Min(11.0 + borderX, availableSize.Width), Math.Min(11.0 + borderY, availableSize.Height)); 213Math.Max(0, bounds.Width - thickness.Left - thickness.Right), 214Math.Max(0, bounds.Height - thickness.Top - thickness.Bottom)); 455Math.Max(0.0, rt.Width - thick.Left - thick.Right), 456Math.Max(0.0, rt.Height - thick.Top - thick.Bottom));
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\DataGridHeaderBorder.cs (5)
193childWidth = Math.Max(0.0, childWidth - padding.Left - padding.Right); 198childHeight = Math.Max(0.0, childHeight - padding.Top - padding.Bottom); 233double childWidth = Math.Max(0.0, arrangeSize.Width - padding.Left - padding.Right); 234double childHeight = Math.Max(0.0, arrangeSize.Height - padding.Top - padding.Bottom); 300return Math.Max(0.0, d);
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\ProgressBarBrushConverter.cs (2)
84int blocks = (int)Math.Ceiling(width / blockTotal); 159if (!isIndeterminate && remainder > 0.0 && Math.Abs(width - trackWidth) < 1.0e-5)
src\Microsoft.DotNet.Wpf\src\Themes\Shared\Microsoft\Windows\Themes\SystemDropShadowChrome.cs (5)
112double maxRadius = Math.Min(centerWidth * 0.5, centerHeight * 0.5); 113cornerRadius.TopLeft = Math.Min(cornerRadius.TopLeft, maxRadius); 114cornerRadius.TopRight = Math.Min(cornerRadius.TopRight, maxRadius); 115cornerRadius.BottomLeft = Math.Min(cornerRadius.BottomLeft, maxRadius); 116cornerRadius.BottomRight = Math.Min(cornerRadius.BottomRight, maxRadius);
PresentationUI (6)
MS\Internal\Documents\CredentialManagerDialog.cs (1)
162int maxWidth = Math.Max(_addButton.Width, _removeButton.Width);
MS\Internal\Documents\SignatureSummaryDialog.cs (4)
571int h = Math.Max(Math.Max(Math.Max(Math.Max(IconHeight,heightSummary), heightIntent), heightLocale), heightSignBy);
TenFeetInstallationProgress.xaml.cs (1)
123double percentDone = Math.Floor((double)bytesDownloaded / (double)bytesTotal * 100.0);
ReachFramework (93)
AlphaFlattener\BrushProxy.cs (32)
512rb.RadiusX = Math.Abs(rb.RadiusX * bounds.Width); 513rb.RadiusY = Math.Abs(rb.RadiusY * bounds.Height); 1912double length = Math.Sqrt(dx * dx + dy * dy); 1926stopDistance = Math.Max(b.RadiusX, b.RadiusY) * (second.Offset - first.Offset); 1944int stopCount = (int)Math.Ceiling(-6.297427 + 4.591693 * Math.Log(stopDistance)); 2283double height = Math.Abs(start.Y - end.Y) * multiplier; 2292double width = Math.Abs(start.X - end.X) * multiplier; 2573if (Utility.AreClose(new Vector(Math.Abs(rbA.RadiusX), Math.Abs(rbA.RadiusY)) * rbA.Transform.Value, 2574new Vector(Math.Abs(rbB.RadiusX), Math.Abs(rbB.RadiusY)) * rbB.Transform.Value)) 3742min = Math.Min(min, offset); 3743max = Math.Max(max, offset); 3869return Math.Sqrt(sum); 3898return (int)Math.Ceiling(Math.Max(5, step)); // At least five. Radials look bad with less steps. 3947if (Math.Abs(di) < Double.Epsilon) 4041double right = Math.Ceiling(_bounds.Right / _bandDelta); 4042double left = Math.Floor(_bounds.Left / _bandDelta); 4141double rotateAngle = Math.Atan2(-gradientVector.Y, gradientVector.X) * 180.0 / Math.PI; 4186_rx = Math.Abs(b.RadiusX); 4187_ry = Math.Abs(b.RadiusY); 4268double right = Math.Ceiling(maxt * _bandSteps); 4269double left = Math.Floor(mint * _bandSteps); 4384double root = Math.Sqrt(B4AC); 4393maxt = Math.Max(maxt, one); 4394mint = Math.Min(mint, one); 4401maxt = Math.Max(maxt, two); 4402mint = Math.Min(mint, two); 4427double len = Math.Sqrt(dx * dx + dy * dy);
AlphaFlattener\DrawingContext.cs (3)
602int width = (int) Math.Round(bounds.Width * Configuration.RasterizationDPI / 96); 603int height = (int) Math.Round(bounds.Height * Configuration.RasterizationDPI / 96); 660return 512 + Configuration.RasterizationCost(Math.Max(bounds.Width, bounds.Height));
AlphaFlattener\Flattener.cs (2)
1226uint dcDpi = Math.Max(PrintQueue.GetDpiX(dc), PrintQueue.GetDpiY(dc)); 1227Configuration.RasterizationDPI = (int)(Math.Max(dcDpi, 300));
AlphaFlattener\ImageProxy.cs (6)
481int x0 = (int)Math.Max(Math.Floor(bounds.Left), 0); 482int y0 = (int)Math.Max(Math.Floor(bounds.Top), 0); 483int x1 = (int)Math.Ceiling(bounds.Right); 484int y1 = (int)Math.Ceiling(bounds.Bottom);
AlphaFlattener\Optimizer.cs (2)
47int width = (int)Math.Round(m_bounds.Width * Configuration.RasterizationDPI / 96); 48int height = (int)Math.Round(m_bounds.Height * Configuration.RasterizationDPI / 96);
AlphaFlattener\Primitive.cs (2)
762columnCount = (int)Math.Ceiling((bounds.Right - startTile.Left) / startTile.Width); 771rowCount = (int)Math.Ceiling((bounds.Bottom - startTile.Top) / startTile.Height);
AlphaFlattener\Utility.cs (10)
104return Math.Abs(value - 1.0) < Epsilon; 113return Math.Abs(value) < Epsilon; 150double s = Math.Round(scale); 175scale = Math.Sqrt(A); 186x = Math.Abs(x); 187y = Math.Abs(y); 208return y * Math.Sqrt(r * r + 1.0); 224return Math.Max(GetScaleX(trans), GetScaleY(trans)); 1678scale = Math.Min(viewport.Width / viewbox.Width, viewport.Height / viewbox.Height); 1687scale = Math.Max(viewport.Width / viewbox.Width, viewport.Height / viewbox.Height);
MS\Internal\Printing\Configuration\COMPSTUISRID.cs (2)
40resString.Length = Math.Max(0, Math.Min(charCount, resString.Length));
MS\Internal\Printing\Configuration\DevMode.cs (1)
629int charsToWrite = Math.Min(value.Length, maxCharsToWrite - 1);
PrintConfig\FallbackPTProvider.cs (2)
156defaultCopies = Math.Max(minCopies, Math.Min(defaultDevMode.Copies, maxCopies));
PrintConfig\PrintSchemaShim.cs (2)
1179return (short)Math.Max(min, Math.Min(value, max));
PrintConfig\PTProvider.cs (5)
675int bytesToWrite = Math.Min(data.Length, (int)(byteCount - totalBytesWritten)); 729int bytesToRead = Math.Min(data.Length, (int)(byteCount - totalBytesRead)); 817return (int)Math.Max(0, Math.Min(value, int.MaxValue)); 822return (int)Math.Min(value, int.MaxValue);
Serialization\DrawingContextFlattener.cs (12)
463const double PI_OVER_180 = Math.PI / 180; // PI/180 572rAngle = Math.Atan2(rSinArcAngle, rCosArcAngle); 578rAngle += Math.PI * 2; 585rAngle -= Math.PI * 2; 590rCosArcAngle = Math.Cos(rAngle); 591rSinArcAngle = Math.Sin(rAngle); 670rSin = Math.Sqrt(rSin); // = R*cos(a) 671rCos = Math.Sqrt(rCos); // = R*sin(a) 752double rCos = Math.Cos(rRotation); 753double rSin = Math.Sin(rRotation); 774r = Math.Sqrt(rHalfChord2); 788r = Math.Sqrt((1 - rHalfChord2) / rHalfChord2);
Serialization\Manager\ReachSerializationUtils.cs (2)
168System.Windows.DependencyProperty[] newList = new System.Windows.DependencyProperty[Math.Max(List.Length * 2, Count + delta)]; 175List = new System.Windows.DependencyProperty[Math.Max(delta, 2)];
Serialization\VisualSerializer.cs (10)
468scalex = Math.Min(dstwidth / srcwidth, dstheight / srcheight); 473scalex = 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.VisualStudio.DiagnosticsWindow (1)
PerfMargin\StatusIndicator.xaml.cs (1)
65this.clipScale.ScaleX = Math.Max(this.clipScale.ScaleX, MinimumScale);
Roslyn.VisualStudio.Next.UnitTests (1)
Services\PerformanceTrackerServiceTests.cs (1)
157to = Math.Min(to, dataCount);
ScenarioTests.Common.Tests (1)
ScenarioTestTypes.cs (1)
1037var numberOfBytesInThisRead = (int)Math.Min(count, _length - _position);
SemanticSearch.BuildTask (1)
src\Compilers\Core\Portable\InternalUtilities\Hash.cs (1)
97var maxSize = Math.Min(maxItemsToHash, values.Length);
SignalRSamples (2)
Hubs\UploadHub.cs (2)
44return $"{winner} wins with a total of {Math.Max(p1score, p2score)} points to {Math.Min(p1score, p2score)}";
Sockets.FunctionalTests (3)
src\Servers\Kestrel\test\FunctionalTests\MaxRequestBufferSizeTests.cs (2)
149var size = Math.Min(data.Length - bytesWritten, maxSendSize); 242var size = Math.Min(data.Length - bytesWritten, maxSendSize);
src\Servers\Kestrel\test\FunctionalTests\ResponseTests.cs (1)
1127var received = await stream.ReadAsync(receiveBuffer, 0, Math.Min(receiveBuffer.Length, expectedBytes - totalReceived));
Stress.ApiService (1)
TraceCreator.cs (1)
111var activityLinkCount = Random.Shared.Next(0, Math.Min(5, _allActivities.Count));
Swaggatherer (2)
SwaggathererApplication.cs (2)
257var length = Math.Min(text.Length, Math.Max(5, part.Name.Length));
System.Collections (5)
src\libraries\System.Private.CoreLib\src\System\Collections\HashHelpers.cs (1)
44int limit = (int)Math.Sqrt(candidate);
System\Collections\Generic\PriorityQueue.cs (4)
62Debug.Assert(Log2Arity > 0 && Math.Pow(2, Log2Arity) == Arity); 638newcapacity = Math.Max(newcapacity, _nodes.Length + MinimumGrow); 800int childIndexUpperBound = Math.Min(i + Arity, size); 849int childIndexUpperBound = Math.Min(i + Arity, size);
System.Collections.Concurrent (8)
src\libraries\System.Private.CoreLib\src\System\Collections\HashHelpers.cs (1)
44int limit = (int)Math.Sqrt(candidate);
System\Collections\Concurrent\ConcurrentDictionary.cs (4)
288ICollection<KeyValuePair<TKey, TValue>> c => Math.Max(DefaultCapacity, c.Count), 289IReadOnlyCollection<KeyValuePair<TKey, TValue>> rc => Math.Max(DefaultCapacity, rc.Count), 727_budget = Math.Max(1, newTables._buckets.Length / newTables._locks.Length); 2067_budget = Math.Max(1, newBuckets.Length / newLocks.Length);
System\Collections\Concurrent\PartitionerStatic.cs (3)
451requestedChunkSize = Math.Min(_currentChunkSize.Value * 2, _maxChunkSize); 1101long newSharedIndex = Math.Min(SourceCount - 1, oldSharedIndex + requestedChunkSize); 1370(int quotient, int remainder) = Math.DivRem(SourceCount, partitionCount);
System.Collections.Immutable (11)
src\libraries\System.Private.CoreLib\src\System\Collections\HashHelpers.cs (1)
44int limit = (int)Math.Sqrt(candidate);
System\Collections\Frozen\FrozenHashTable.cs (1)
226Array.Clear(seenBuckets, 0, Math.Min(numBuckets, seenBuckets.Length));
System\Collections\Frozen\String\KeyAnalyzer.cs (1)
74int maxSubstringLength = Math.Min(minLength, MaxSubstringLengthLimit);
System\Collections\Immutable\ImmutableArray_1.Builder.cs (1)
741int newCapacity = Math.Max(_elements.Length * 2, capacity);
System\Collections\Immutable\ImmutableList_1.Node.cs (1)
1517private static byte ParentHeight(Node left, Node right) => checked((byte)(1 + Math.Max(left._height, right._height)));
System\Collections\Immutable\ImmutableSortedDictionary_2.Node.cs (2)
88_height = checked((byte)(1 + Math.Max(left._height, right._height))); 774_height = checked((byte)(1 + Math.Max(_left._height, _right._height)));
System\Collections\Immutable\ImmutableSortedSet_1.Node.cs (2)
90_height = checked((byte)(1 + Math.Max(left._height, right._height))); 765_height = checked((byte)(1 + Math.Max(_left._height, _right._height)));
System\Collections\Immutable\SortedInt32KeyNode.cs (2)
91_height = checked((byte)(1 + Math.Max(left._height, right._height))); 555_height = checked((byte)(1 + Math.Max(_left._height, _right._height)));
System.ComponentModel.TypeConverter (6)
System\ComponentModel\Container.cs (1)
226for (int i = 0; i < Math.Min(_siteCount, _sites!.Length); i++)
System\ComponentModel\EventDescriptorCollection.cs (1)
159int newSize = Math.Max(sizeNeeded, _events.Length * 2);
System\ComponentModel\PropertyDescriptorCollection.cs (1)
166int newSize = Math.Max(sizeNeeded, _properties.Length * 2);
System\Timers\Timer.cs (3)
56double roundedInterval = Math.Ceiling(interval); 139int i = (int)Math.Ceiling(_interval); 156int i = (int)Math.Ceiling(_interval);
System.Console (3)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\TermInfo.Database.cs (1)
240lastEnd = Math.Max(end, lastEnd);
System.Data.Common (88)
System\Data\Common\AdapterUtil.Common.cs (1)
794startIndex = Math.Min(startIndex, index);
System\Data\Common\ByteStorage.cs (3)
95return Math.Sqrt(var); 108min = Math.Min(_values[record], min); 124max = Math.Max(_values[record], max);
System\Data\Common\DBCommandBuilder.cs (1)
241int maxPrefixLength = Math.Max(
System\Data\Common\DbDataAdapter.cs (1)
987int maxBatchCommands = Math.Min(UpdateBatchSize, dataRows.Length);
System\Data\Common\DecimalStorage.cs (3)
98return Math.Sqrt(var); 111min = Math.Min(_values[record], min); 128max = Math.Max(_values[record], max);
System\Data\Common\DoubleStorage.cs (3)
95return Math.Sqrt(var); 108min = Math.Min(_values[record], min); 124max = Math.Max(_values[record], max);
System\Data\Common\Int16Storage.cs (3)
98return Math.Sqrt(var); 112min = Math.Min(_values[record], min); 129max = Math.Max(_values[record], max);
System\Data\Common\Int32Storage.cs (3)
98return Math.Sqrt(var); 111min = Math.Min(_values[record], min); 128max = Math.Max(_values[record], max);
System\Data\Common\Int64Storage.cs (3)
98return Math.Sqrt(var); 111min = Math.Min(_values[record], min); 128max = Math.Max(_values[record], max);
System\Data\Common\ObjectStorage.cs (1)
310Array.Copy(_values, newValues, Math.Min(capacity, _values.Length));
System\Data\Common\SByteStorage.cs (3)
95return Math.Sqrt(var); 108min = Math.Min(_values[record], min); 124max = Math.Max(_values[record], max);
System\Data\Common\SingleStorage.cs (3)
95return Math.Sqrt(var); 109min = Math.Min(_values[record], min); 125max = Math.Max(_values[record], max);
System\Data\Common\SQLTypes\SQLByteStorage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLDecimalStorage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLDoubleStorage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLInt16Storage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLInt32Storage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLInt64Storage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLMoneyStorage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\SQLTypes\SQLSingleStorage.cs (1)
97return Math.Sqrt(var.Value);
System\Data\Common\StringStorage.cs (1)
185Array.Copy(_values, newValues, Math.Min(capacity, _values.Length));
System\Data\Common\TimeSpanStorage.cs (4)
82return TimeSpan.FromTicks((long)Math.Round(sum)); 100return TimeSpan.FromTicks((long)Math.Round(meanSum / meanCount)); 129ulong stDev = (ulong)Math.Round(Math.Sqrt(varSum / (count - 1)));
System\Data\Common\UInt16Storage.cs (3)
98return Math.Sqrt(var); 111min = Math.Min(_values[record], min); 128max = Math.Max(_values[record], max);
System\Data\Common\UInt32Storage.cs (3)
98return Math.Sqrt(var); 111min = Math.Min(_values[record], min); 128max = Math.Max(_values[record], max);
System\Data\Common\UInt64Storage.cs (3)
98return Math.Sqrt(var); 111min = Math.Min(_values[record], min); 128max = Math.Max(_values[record], max);
System\Data\DataColumn.cs (1)
934_maxLength = Math.Max(value, -1);
System\Data\DataError.cs (1)
141int newCapacity = Math.Min(_count * 2, column.Table!.Columns.Count);
System\Data\DataTableReader.cs (2)
368int byteCount = Math.Min(tempBuffer.Length - srcIndex, length); 431int charCount = Math.Min(tempBuffer.Length - srcIndex, length);
System\Data\Filter\BinaryNode.cs (2)
1323DataTypePrecedence higherPrec = (DataTypePrecedence)Math.Max(leftPrecedence, rightPrecedence); 1437DataTypePrecedence higherPrec = (DataTypePrecedence)Math.Max(leftPrecedence, rightPrecedence);
System\Data\Filter\FunctionNode.cs (2)
325return (Math.Abs((long)argumentValues[0])); 327return (Math.Abs((double)argumentValues[0]));
System\Data\ProviderBase\SchemaMapping.cs (2)
299Debug.Assert(_mappedLength == Math.Min(_readerDataValues!.Length, _mappedDataValues!.Length), "incorrect precomputed length"); 1240_mappedLength = Math.Min(count, mappingCount);
System\Data\RecordManager.cs (1)
39Array.Copy(_rows, newRows, Math.Min(_lastFreeRecord, _rows.Length));
System\Data\SQLTypes\SQLBytes.cs (1)
326int count = Math.Min(buffer.Length, (int)(Length - offset));
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); 1251ResInteger = Math.Max(x._bPrec - MyScale, y._bPrec - OpScale); 1255ResScale = Math.Max(MyScale, OpScale); 1261ResPrec = Math.Min(MaxPrecision, ResPrec); 1465ResScale = Math.Min((ResPrec - ResInteger), ResScale); 1467ResScale = Math.Max(ResScale, Math.Min(ActualScale, s_cNumeDivScaleMin)); 1688ResScale = Math.Max(x._bScale + y._bPrec + 1, s_cNumeDivScaleMin); 1691MinScale = Math.Min(ResScale, s_cNumeDivScaleMin); 1693ResInteger = Math.Min(ResInteger, s_NUMERIC_MAX_PRECISION); 1700ResScale = Math.Min((ResPrec - ResInteger), ResScale); 1701ResScale = Math.Max(ResScale, MinScale); 2297bNewPrec = (byte)(Math.Min(s_NUMERIC_MAX_PRECISION, Math.Max(1, lAdjust + _bPrec))); 3168lPosition = Math.Min(s_NUMERIC_MAX_PRECISION, lPosition); 3175lPosition = Math.Max(-s_NUMERIC_MAX_PRECISION, lPosition); 3186int lAdjust = Math.Abs(lPosition - n._bScale); // Precision adjustment 3225lAdjust = Math.Abs(lPosition - n._bScale); 3261n = new SqlDecimal(Math.Pow(dBaseNum, exp));
System.Data.Odbc (28)
Common\System\Data\ProviderBase\DbConnectionPool.cs (1)
617delay = (uint)Math.Max(ADP.TimerRemainingMilliseconds(next.DueTime), 0);
src\libraries\Common\src\System\Data\ProviderBase\DbMetaDataFactory.cs (1)
127command.CommandTimeout = Math.Max(command.CommandTimeout, 180);
System\Data\Odbc\OdbcConnection.cs (2)
399value = (BitConverter.IsLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode).GetString(buffer, 0, Math.Min(cbActual, buffer.Length)); 501value = (BitConverter.IsLittleEndian ? Encoding.Unicode : Encoding.BigEndianUnicode).GetString(buffer, 0, Math.Min(cbActual, buffer.Length));
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\Odbc\OdbcParameter.cs (8)
322return Math.Min((int)_internalPrecision, ADP.DecimalMaxPrecision); 353cch = Math.Max(cch, 4 * 1024); // MDAC 69224 378cch = Math.Max(cch, 4 * 1024); // MDAC 69224 395cch = Math.Max(cch, 8 * 1024); // MDAC 69224 406cch = Math.Max(2, cch); 422return Math.Min((int)_internalPrecision, ADP.DecimalMaxPrecision); 510ccb = Math.Max(ccb, 8 * 1024); // MDAC 69224 546_internalPrecision = Math.Max(_internalPrecision, precision); // silently adjust the precision
System\Data\Odbc\OdbcUtils.cs (4)
39cb = Math.Min(cb / 2, (Length - 2) / 2); 47cb = Math.Min(cb, Length); 172length = Math.Max(0, ((string)value).Length - valueOffset); 187length = Math.Max(0, ((char[])value).Length - valueOffset);
System.Diagnostics.DiagnosticSource (10)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Diagnostics\DsesSamplerBuilder.cs (1)
51return Math.Abs(GetLowerLong(traceIdBytes)) < idUpperBound
System\Diagnostics\Metrics\AggregationManager.cs (1)
212double alignUpSecsSinceStart = Math.Ceiling(secsSinceStart / collectionIntervalSecs) *
System\Diagnostics\Metrics\CounterAggregator.cs (1)
21private readonly PaddedDouble[] _deltas = new PaddedDouble[Math.Min(Environment.ProcessorCount, 8)];
System\Diagnostics\Metrics\ExponentialHistogramAggregator.cs (4)
77int mantissaBits = (int)Math.Ceiling(Math.Log(1 / _config.MaxRelativeError, 2)) - 1; 201return Math.Min(Math.Max(0, (int)(quantile * count)), count - 1);
System\Diagnostics\Metrics\RuntimeMetrics.cs (1)
21private static readonly int s_maxGenerations = Math.Min(GC.GetGCMemoryInfo().GenerationInfo.Length, s_genNames.Length);
System.Diagnostics.Process (6)
src\libraries\Common\src\System\Collections\Generic\ArrayBuilder.cs (2)
148nextCapacity = Math.Max(capacity + 1, Array.MaxLength); 151nextCapacity = Math.Max(nextCapacity, minimum);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Diagnostics\ProcessWaitState.Unix.cs (2)
427(int)Math.Max(millisecondsTimeout - Stopwatch.GetElapsedTime(startTime).TotalMilliseconds, 0); 538pollingIntervalMs = Math.Min(pollingIntervalMs * 2, MaxPollingIntervalMs);
System.Diagnostics.TextWriterTraceListener (1)
System\Diagnostics\XmlWriterTraceListener.cs (1)
231InternalWrite(Math.Clamp((int)eventType, 0, 255));
System.Drawing.Common.Tests (16)
mono\System.Drawing\BitmapTests.cs (6)
223Assert.Equal(Math.Ceiling((float)c.B * c.A / 255), data[0]); 224Assert.Equal(Math.Ceiling((float)c.G * c.A / 255), data[1]); 225Assert.Equal(Math.Ceiling((float)c.R * c.A / 255), data[2]); 227Assert.Equal(Math.Ceiling((float)d.B * d.A / 255), data[4]); 228Assert.Equal(Math.Ceiling((float)d.G * d.A / 255), data[5]); 229Assert.Equal(Math.Ceiling((float)d.R * d.A / 255), data[6]);
System\Drawing\BitmapTests.cs (6)
1355Assert.Equal(Math.Ceiling((float)c.B * c.A / 255), data[0]); 1356Assert.Equal(Math.Ceiling((float)c.G * c.A / 255), data[1]); 1357Assert.Equal(Math.Ceiling((float)c.R * c.A / 255), data[2]); 1359Assert.Equal(Math.Ceiling((float)d.B * d.A / 255), data[4]); 1360Assert.Equal(Math.Ceiling((float)d.G * d.A / 255), data[5]); 1361Assert.Equal(Math.Ceiling((float)d.R * d.A / 255), data[6]);
System\Drawing\Drawing2D\GraphicsPathTests.cs (2)
30private const float Pi4 = (float)(Math.PI / 4); 2071AssertExtensions.LessThanOrEqualTo(Math.Abs(expexted - actual), tollerance);
System\Drawing\FontTests.cs (1)
494Assert.Equal((int)Math.Ceiling(height), font.Height);
System\Drawing\IconTests.cs (1)
117public override int Read(byte[] buffer, int offset, int count) => base.Read(buffer, offset, Math.Min(count, 1));
System.Drawing.Primitives (32)
System\Drawing\Point.cs (4)
123public static Point Ceiling(PointF value) => new Point(unchecked((int)Math.Ceiling(value.X)), unchecked((int)Math.Ceiling(value.Y))); 133public static Point Round(PointF value) => new Point(unchecked((int)Math.Round(value.X)), unchecked((int)Math.Round(value.Y)));
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\Drawing\RectangleF.cs (8)
273float x1 = Math.Max(a.X, b.X); 274float x2 = Math.Min(a.X + a.Width, b.X + b.Width); 275float y1 = Math.Max(a.Y, b.Y); 276float y2 = Math.Min(a.Y + a.Height, b.Y + b.Height); 297float x1 = Math.Min(a.X, b.X); 298float x2 = Math.Max(a.X + a.Width, b.X + b.Width); 299float y1 = Math.Min(a.Y, b.Y); 300float y2 = Math.Max(a.Y + a.Height, b.Y + b.Height);
System\Drawing\Size.cs (4)
157new Size(unchecked((int)Math.Ceiling(value.Width)), unchecked((int)Math.Ceiling(value.Height))); 174new Size(unchecked((int)Math.Round(value.Width)), unchecked((int)Math.Round(value.Height)));
System.Formats.Asn1 (6)
System\Formats\Asn1\AsnDecoder.cs (1)
641int len = Math.Min(longestPermitted, source.Length);
System\Formats\Asn1\AsnDecoder.Oid.cs (1)
208idx = Math.Max(0, nextStop - ContentByteCount);
System\Formats\Asn1\AsnWriter.BitString.cs (1)
113int fullSegments = Math.DivRem(contentLength, MaxCERContentSize, out int lastContentSize);
System\Formats\Asn1\AsnWriter.OctetString.cs (1)
111int fullSegments = Math.DivRem(payload.Length, MaxCERSegmentSize, out int lastSegmentSize);
System\Formats\Asn1\AsnWriter.Oid.cs (1)
176oidValue = oidValue.Slice(Math.Min(oidValue.Length, endIndex + 1));
System\Formats\Asn1\SetOfValueComparer.cs (1)
17int min = Math.Min(x.Length, y.Length);
System.Formats.Nrbf (3)
System\Formats\Nrbf\ArraySinglePrimitiveRecord.cs (2)
134int sliceSize = Math.Min(valuesToRead.Length, MaxChunkLength); 256List<T> values = new List<T>(Math.Min(count, 4));
System\Formats\Nrbf\RectangularArrayRecord.cs (1)
30_records = new List<SerializationRecord>(Math.Min(4, arrayInfo.GetSZArrayLength()));
System.Formats.Tar (13)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Formats\Tar\SeekableSubReadStream.cs (1)
54count = Math.Max(0, (int)(_endInSuperStream - _positionInSuperStream));
System\Formats\Tar\TarHeader.Write.cs (2)
1026int numToCopy = Math.Min(bytesToWrite.Length, destination.Length); 1043int numToCopy = Math.Min(bytesToWrite.Length, destination.Length - 1);
System\Formats\Tar\TarHelpers.cs (8)
60byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToDiscard)); 63int currentLengthToRead = (int)Math.Min(MaxBufferLength, bytesToDiscard); 82byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToDiscard)); 85int currentLengthToRead = (int)Math.Min(MaxBufferLength, bytesToDiscard); 96byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToCopy)); 99int currentLengthToRead = (int)Math.Min(MaxBufferLength, bytesToCopy); 112byte[] buffer = ArrayPool<byte>.Shared.Rent(minimumLength: (int)Math.Min(MaxBufferLength, bytesToCopy)); 115int currentLengthToRead = (int)Math.Min(MaxBufferLength, bytesToCopy);
System.IO.Compression (6)
System\IO\Compression\DeflateManaged\InflaterManaged.cs (1)
115bytes = bytes.Slice(0, (int)Math.Min(bytes.Length, _uncompressedSize - _currentInflatedCount));
System\IO\Compression\DeflateManaged\InputBuffer.cs (1)
149int length = Math.Min(output.Length, _buffer.Length);
System\IO\Compression\DeflateManaged\OutputWindow.cs (2)
88length = Math.Min(Math.Min(length, WindowSize - _bytesUsed), input.AvailableBytes);
System\IO\Compression\DeflateZLib\Inflater.cs (1)
101length = (int)Math.Min(length, _uncompressedSize - _currentInflatedCount);
System\IO\Compression\ZipHelper.cs (1)
162int numBytesToSkip = (int)Math.Min(numBytesLeft, buffer.Length);
System.IO.FileSystem.Watcher (2)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System.IO.Hashing (1)
System\IO\Hashing\XxHashShared.cs (1)
456return Math.BigMul(left, right, out lower);
System.IO.Pipelines (8)
System\IO\Pipelines\Pipe.cs (3)
262sizeHint = Math.Max(MinimumSegmentSize, sizeHint); 264int adjustedToMaximumSize = Math.Min(maxBufferSize, sizeHint); 1104int writable = Math.Min(destination.Length, source.Length);
System\IO\Pipelines\PipeReaderStream.cs (1)
126int actual = (int)Math.Min(bufferLength, buffer.Length);
System\IO\Pipelines\StreamPipeReader.cs (2)
537sizeHint = Math.Max(BufferSize, sizeHint); 539int adjustedToMaximumSize = Math.Min(maxBufferSize, sizeHint);
System\IO\Pipelines\StreamPipeWriter.cs (2)
178sizeHint = Math.Max(_minimumBufferSize, sizeHint); 180var adjustedToMaximumSize = Math.Min(maxBufferSize, sizeHint);
System.IO.Ports (5)
System\IO\Ports\SerialPort.cs (4)
675bytesReadToBuffer = Math.Min(CachedBytesToRead, count); 891int bytesToRead = Math.Min(count, CachedBytesToRead); 923currentBytesToExamine = Math.Min(count - totalCharsFound, _readLen - _readPos - totalBytesExamined); 1330int newLength = Math.Max(CachedBytesToRead + additionalByteLength, _inBuffer.Length * 2);
System\IO\Ports\SerialStream.Unix.cs (1)
1070new CancellationTokenSource(Math.Max(timeoutMs, TimeoutResolution));
System.Linq (15)
System\Linq\Chunk.cs (3)
66TSource[] chunk = new ReadOnlySpan<TSource>(source, index, Math.Min(size, source.Length - index)).ToArray(); 82int arraySize = Math.Min(size, 4); 99arraySize = (int)Math.Min((uint)size, 2 * (uint)array.Length);
System\Linq\SegmentedArrayBuilder.cs (3)
145ReadOnlySpan<T> sourceSlice = sourceSpan.Slice(0, Math.Min(availableSpaceInCurrentSpan, sourceSpan.Length)); 354int newSegmentLength = (int)Math.Min(Math.Max(minimumRequired, currentSegmentLength * 2L), Array.MaxLength);
System\Linq\Select.SpeedOpt.cs (2)
871return _selector(_source[Math.Min(lastIndex, _maxIndexInclusive)]); 888return Math.Min(count - 1, _maxIndexInclusive) - _minIndexInclusive + 1;
System\Linq\SkipTake.SpeedOpt.cs (4)
97return _source[Math.Min(lastIndex, _maxIndexInclusive)]; 114return Math.Min(count - 1, _maxIndexInclusive) - _minIndexInclusive + 1; 258return Math.Max(_source.Count() - _minIndexInclusive, 0); 274return Math.Max((int)count - _minIndexInclusive, 0);
System\Linq\Take.cs (3)
135Debug.Assert(queue.Count == Math.Min(count, startIndex)); 184Math.Max(0, isStartIndexFromEnd ? count - startIndex : startIndex); 187Math.Min(count, isEndIndexFromEnd ? count - endIndex : endIndex);
System.Linq.Expressions (8)
src\libraries\Common\src\System\Collections\Generic\ArrayBuilder.cs (2)
148nextCapacity = Math.Max(capacity + 1, Array.MaxLength); 151nextCapacity = Math.Max(nextCapacity, minimum);
System\Linq\Expressions\Common\CachedReflectionInfo.cs (2)
135s_Math_Pow_Double_Double ??= typeof(Math).GetMethod(nameof(Math.Pow), new[] { typeof(double), typeof(double) })!;
System\Linq\Expressions\Compiler\LambdaCompiler.Statements.cs (1)
419keys.Sort((x, y) => Math.Sign(x.Key - y.Key));
System\Linq\Expressions\DebugViewWriter.cs (1)
203return (Flow)System.Math.Max((int)last, (int)flow);
System\Linq\Expressions\Interpreter\LocalVariables.cs (1)
76_maxLocalCount = Math.Max(_localCount, _maxLocalCount);
System\Runtime\CompilerServices\RuleCache.cs (1)
47int max = Math.Min(_rules.Length, i + count);
System.Linq.Parallel (5)
System\Linq\Parallel\QueryOperators\Binary\ZipQueryOperator.cs (1)
184_count = Math.Min(_leftChildResults.Count, _rightChildResults.Count);
System\Linq\Parallel\QueryOperators\Unary\TakeOrSkipQueryOperator.cs (2)
377return Math.Min(_childCount, _takeOrSkipOp._count); 381return Math.Max(_childCount - _takeOrSkipOp._count, 0);
System\Linq\Parallel\Scheduling\Scheduling.cs (1)
34internal static readonly int DefaultDegreeOfParallelism = Math.Min(Environment.ProcessorCount, MAX_SUPPORTED_DOP);
System\Linq\Parallel\Utils\Sorting.cs (1)
384_sharedBarriers[phase][Math.Min(_partitionIndex, partnerIndex)].SignalAndWait(cancelToken);
System.Memory (4)
src\libraries\Common\src\System\Buffers\ArrayBufferWriter.cs (2)
214int growBy = Math.Max(sizeHint, currentLength); 218growBy = Math.Max(growBy, DefaultInitialBufferSize);
System\Buffers\BuffersExtensions.cs (1)
137int writeSize = Math.Min(destination.Length, input.Length);
System\Buffers\SequenceReader.cs (1)
444int toCopy = Math.Min(nextSpan.Length, destination.Length - copied);
System.Memory.Data (1)
System\BinaryData.cs (1)
296bufferSize = longLength == 0 ? 1 : Math.Min((int)longLength, CopyToBufferSize);
System.Net.Http (51)
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\DynamicTable.cs (1)
83int headCount = Math.Min(_buffer.Length - _removeIndex, _count);
src\libraries\Common\src\System\Net\Http\aspnetcore\Http2\Hpack\HPackDecoder.cs (6)
420int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 458int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 580_stringOctets = new byte[Math.Max(length, Math.Min(_stringOctets.Length * 2, _maxHeadersLength))]; 629dst = new byte[Math.Max(stringLength, Math.Min(dst.Length * 2, _maxHeadersLength))];
src\libraries\Common\src\System\Net\Http\aspnetcore\Http3\QPack\QPackDecoder.cs (2)
287int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex); 373int count = Math.Min(_stringLength - _stringIndex, data.Length - currentIndex);
src\libraries\Common\src\System\Net\MultiArrayBuffer.cs (1)
140byteCount = Math.Min(byteCount, limit - ActiveMemory.Length);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Net\Http\Headers\AltSvcHeaderParser.cs (1)
140maxAge = Math.Min(maxAge.GetValueOrDefault(), maxAgeTmp);
System\Net\Http\HttpContent.cs (5)
928int newBufferCapacity = (int)Math.Min((uint)lastBufferCapacity * ResizeFactor, Array.MaxLength); 931newBufferCapacity = Math.Max(newBufferCapacity, _totalLength + buffer.Length); 938: Math.Min(_expectedFinalSize, MaxInitialBufferSize / LastResizeFactor); 940newBufferCapacity = Math.Max(newBufferCapacity, minCapacity); 947newBufferCapacity = Math.Min(newBufferCapacity, remainingUntilMaxCapacity);
System\Net\Http\SocketsHttpHandler\ChunkedEncodingReadStream.cs (4)
73int bytesRead = _connection.Read(buffer.Slice(0, (int)Math.Min((ulong)buffer.Length, _chunkBytesRemaining))); 189int bytesRead = await _connection.ReadAsync(buffer.Slice(0, (int)Math.Min((ulong)buffer.Length, _chunkBytesRemaining))).ConfigureAwait(false); 367int bytesToConsume = Math.Min(maxBytesToRead, (int)Math.Min((ulong)connectionBuffer.Length, _chunkBytesRemaining));
System\Net\Http\SocketsHttpHandler\ConnectionPool\RequestQueue.cs (1)
93var newArray = new QueueItem[Math.Max(4, _array.Length * 2)];
System\Net\Http\SocketsHttpHandler\ContentLengthReadStream.cs (2)
184int bytesToConsume = Math.Min(maxBytesToRead, (int)Math.Min((ulong)connectionBuffer.Length, _contentBytesRemaining));
System\Net\Http\SocketsHttpHandler\CreditManager.cs (2)
106int granted = Math.Min(waiter.Amount, _current); 169int granted = Math.Min(amount, _current);
System\Net\Http\SocketsHttpHandler\Http2Connection.cs (2)
431string response = Encoding.ASCII.GetString(_incomingBuffer.ActiveSpan.Slice(0, Math.Min(20, _incomingBuffer.ActiveLength))); 1705int frameSize = Math.Min(remaining.Length, FrameHeader.MaxPayloadLength);
System\Net\Http\SocketsHttpHandler\Http2Stream.cs (3)
484int granted = Math.Min(_availableCredit, _creditWaiter.Amount); 1116int bytesRead = Math.Min(buffer.Length, activeBuffer.Length); 1285sendSize = Math.Min(buffer.Length, _availableCredit);
System\Net\Http\SocketsHttpHandler\Http2StreamWindowManager.cs (2)
114int extendedWindowSize = Math.Min(MaxStreamWindowSize, _streamWindowSize * 2); 273long minRtt = Math.Min(prevRtt, currentRtt.Ticks);
System\Net\Http\SocketsHttpHandler\Http3Connection.cs (2)
850_maxHeaderListSize = (uint)Math.Min((ulong)settingValue, uint.MaxValue); 914long readLength = Math.Min(payloadLength, buffer.ActiveLength);
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (9)
77_headerDecoder = new QPackDecoder(maxHeadersLength: (int)Math.Min(int.MaxValue, _headerBudgetRemaining)); 931int processLength = (int)Math.Min(headersLength, _recvBuffer.ActiveLength); 1131long readLength = Math.Min(payloadLength, _recvBuffer.ActiveLength); 1162int copyLen = (int)Math.Min(buffer.Length, Math.Min(_responseDataPayloadRemaining, _recvBuffer.ActiveLength)); 1182int copyLen = (int)Math.Min(buffer.Length, _responseDataPayloadRemaining); 1234int copyLen = (int)Math.Min(buffer.Length, Math.Min(_responseDataPayloadRemaining, _recvBuffer.ActiveLength)); 1254int copyLen = (int)Math.Min(buffer.Length, _responseDataPayloadRemaining);
System\Net\Http\SocketsHttpHandler\HttpConnection.cs (3)
1747int toCopy = Math.Min(available.Length, buffer.Length); 1951remaining = (int)Math.Min((ulong)_readBuffer.ActiveLength, length); 1969int desiredBufferSize = (int)Math.Min((ulong)bufferSize, length);
System\Net\Http\SocketsHttpHandler\HttpConnectionPoolManager.cs (2)
114long heartBeatInterval = (long)Math.Max(1000, Math.Min(_settings._keepAlivePingDelay.TotalMilliseconds, _settings._keepAlivePingTimeout.TotalMilliseconds) / 4);
System\Net\Http\SocketsHttpHandler\HttpConnectionSettings.cs (1)
142public int MaxResponseHeadersByteLength => (int)Math.Min(int.MaxValue, _maxResponseHeadersLength * 1024L);
System.Net.HttpListener (10)
src\libraries\Common\src\System\Net\Logging\NetEventSource.Common.DumpBuffer.cs (1)
35Log.DumpBuffer(IdOf(thisOrContextObject), memberName, buffer.Slice(0, Math.Min(buffer.Length, MaxDumpSize)).ToArray());
System\Net\Managed\ChunkedInputStream.cs (1)
142ares._count = Math.Min(8192, _decoder.ChunkLeft + 6);
System\Net\Managed\HttpListenerRequest.Managed.cs (1)
263length = (int)Math.Min(_contentLength, (long)length);
System\Net\Managed\HttpRequestStream.Managed.cs (6)
76int size = Math.Min(_length, count); 78size = (int)Math.Min(size, _remainingBody); 82size = Math.Min(size, _buffer.Length - _offset); 110size = (int)Math.Min(_remainingBody, (long)size); 149ares._synchRead = Math.Max(0, nread); 158size = (int)Math.Min(_remainingBody, (long)size);
System\Net\Managed\HttpResponseStream.Managed.cs (1)
184int new_count = Math.Min(size, 16384 - (int)ms.Position + (int)start);
System.Net.Mail (7)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Net\BufferedReadStream.cs (2)
53read = Math.Min(count, _storedLength - _storedOffset); 75read = Math.Min(count, _storedLength - _storedOffset);
System\Net\Mail\SmtpReplyReaderFactory.cs (2)
327int left = Math.Min(4 - statusRead, actual); 461int left = Math.Min(4 - _statusRead, actual);
System\Net\Mime\SmtpDateTime.cs (1)
343if (Math.Abs(sanitizedTimeSpan.Ticks) > TimeSpanMaxTicks)
System.Net.NameResolution (1)
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (1)
181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System.Net.NetworkInformation (1)
System\Net\NetworkInformation\StringParsingHelpers.Statistics.cs (1)
458return (long)Math.Min(long.MaxValue, ulong.Parse(value, CultureInfo.InvariantCulture));
System.Net.Ping (4)
src\libraries\Common\src\System\Net\NetworkInformation\UnixCommandLinePing.cs (2)
128timeout = Math.DivRem(timeout, millisInSecond, out int remainder); 217return (long)Math.Round(parsedRtt);
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (1)
181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System\Net\NetworkInformation\Ping.PingUtility.cs (1)
140int addressLength = stdout.AsSpan(Math.Max(addressStart, 0)).IndexOfAny(' ', ':');
System.Net.Primitives (8)
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (1)
181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System\Net\CookieContainer.cs (3)
423int min_count = Math.Min((int)(domain_count * remainingFraction), Math.Min(m_maxCookiesPerDomain, m_maxCookies) - 1); 1118int length = Math.Min(ll, lr);
System\Net\IPAddressParser.cs (4)
159(uint hundredsAndTens, number) = Math.DivRem(number, 10); 160(hundreds, tens) = Math.DivRem(hundredsAndTens, 10); 168(tens, number) = Math.DivRem(number, 10); 213(scopeId, uint digit) = Math.DivRem(scopeId, 10);
System.Net.Quic (5)
src\libraries\Common\src\System\Net\MultiArrayBuffer.cs (1)
140byteCount = Math.Min(byteCount, limit - ActiveMemory.Length);
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (1)
181buffer[0] = (byte)Math.Min(buffer.Length, 255);
src\libraries\Common\src\System\Net\StreamBuffer.cs (2)
112int bytesWritten = Math.Min(buffer.Length, _buffer.AvailableMemory.Length); 205int bytesRead = Math.Min(buffer.Length, _buffer.ActiveMemory.Length);
System\Net\Quic\Internal\ReceiveBuffers.cs (1)
77copied = Math.Min(buffer.Length, activeBuffer.Length);
System.Net.Requests (4)
System\Net\HttpWebResponse.cs (2)
403int readBytes = innerStream.Read(buffer.Slice(0, (int)Math.Min(buffer.Length, _maxRemainingLength))); 415int readBytes = await innerStream.ReadAsync(buffer.Slice(0, (int)Math.Min(buffer.Length, _maxRemainingLength)), cancellationToken)
System\Net\ServicePoint\ServicePointManager.cs (1)
91set { s_dnsRefreshTimeout = Math.Max(-1, value); }
System\Net\TimerThread.cs (1)
549Math.Min(unchecked((uint)(nextTick - newNow)), (uint)(int.MaxValue - TickCountResolution)) + TickCountResolution :
System.Net.Security (6)
src\libraries\Common\src\System\Net\Logging\NetEventSource.Common.DumpBuffer.cs (1)
35Log.DumpBuffer(IdOf(thisOrContextObject), memberName, buffer.Slice(0, Math.Min(buffer.Length, MaxDumpSize)).ToArray());
System\Net\Security\NegotiateStream.cs (3)
354int copyBytes = Math.Min(_readBufferCount, buffer.Length); 430int copyBytes = Math.Min(_readBufferCount, buffer.Length); 520int chunkBytes = Math.Min(buffer.Length, MaxWriteDataSize);
System\Net\Security\SslStream.IO.cs (2)
617int chunkBytes = Math.Min(buffer.Length, MaxDataSize); 1001int copyBytes = Math.Min(_buffer.DecryptedLength, buffer.Length);
System.Net.ServerSentEvents (3)
System\Net\ServerSentEvents\PooledByteBufferWriter.cs (2)
18_buffer.EnsureAvailableSpace(Math.Max(sizeHint, MinimumBufferSize)); 24_buffer.EnsureAvailableSpace(Math.Max(sizeHint, MinimumBufferSize));
System\Net\ServerSentEvents\SseParser_1.cs (1)
543buffer = ArrayPool<byte>.Shared.Rent(Math.Max(minimumLength, DefaultArrayPoolRentSize));
System.Net.Sockets (8)
src\libraries\Common\src\System\Net\Logging\NetEventSource.Common.DumpBuffer.cs (1)
35Log.DumpBuffer(IdOf(thisOrContextObject), memberName, buffer.Slice(0, Math.Min(buffer.Length, MaxDumpSize)).ToArray());
src\libraries\Common\src\System\Net\SocketAddressPal.Unix.cs (1)
181buffer[0] = (byte)Math.Min(buffer.Length, 255);
System\Net\Sockets\SocketAsyncEngine.Unix.cs (3)
57return Math.Max(1, (int)Math.Round(Environment.ProcessorCount / (double)coresPerEngine)); 113int engineIndex = Math.Abs(Interlocked.Increment(ref s_allocateFromEngine) % s_engines.Length);
System\Net\Sockets\SocketPal.Unix.cs (3)
296maxBuffers = Math.Max(maxBuffers, 1); 388maxBuffers = Math.Max(maxBuffers, 1); 549buffersCount = Math.Max(buffersCount, 1);
System.Net.WebClient (6)
src\libraries\Common\src\System\IO\ChunkedMemoryStream.cs (2)
50int toCopy = Math.Min(remaining, buffer.Length); 90nextChunkLength = (int)Math.Min(count, MaxChunkSize);
System\Net\WebClient.cs (4)
527buffSize = (int)Math.Min(DefaultCopyBufferLength, fs.Length); 540buffSize = (int)Math.Min(DefaultCopyBufferLength, fs.Length); 1435chunkSize = (int)Math.Min((long)DefaultCopyBufferLength, data.Length); 1511chunkSize = (int)Math.Min((long)DefaultCopyBufferLength, buffer.Length);
System.Net.WebSockets (8)
System\Net\WebSockets\Compression\WebSocketDeflater.cs (1)
49_buffer = ArrayPool<byte>.Shared.Rent(Math.Max(payload.Length, MinInitialBufferLength));
System\Net\WebSockets\Compression\WebSocketInflater.cs (1)
83_buffer = ArrayPool<byte>.Shared.Rent((int)Math.Min(userBufferLength, payloadLength));
System\Net\WebSockets\ManagedWebSocket.cs (2)
924int limit = (int)Math.Min(header.Compressed ? _inflater!.Span.Length : payloadBuffer.Length, header.PayloadLength); 928int receiveBufferBytesToCopy = Math.Min(limit, _receiveBufferCount);
System\Net\WebSockets\ManagedWebSocket.KeepAlive.cs (3)
181internal int HeartBeatIntervalMs => Math.Max(Math.Min(DelayMs, TimeoutMs) / 4, MinIntervalMs); 197static int TimeSpanToMs(TimeSpan value) => (int)Math.Clamp((long)value.TotalMilliseconds, MinIntervalMs, int.MaxValue);
System\Net\WebSockets\WebSocket.cs (1)
117return new ArraySegment<byte>(new byte[Math.Max(receiveBufferSize, sendBufferSize)]);
System.Numerics.Tensors (19)
System\Numerics\Tensors\netcore\Common\TensorPrimitives.IAggregationOperator.cs (6)
236(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector128<T>.Count); 418(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector256<T>.Count); 600(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector512<T>.Count); 1375(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector128<T>.Count); 1582(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector256<T>.Count); 1789(nuint blocks, nuint trailing) = Math.DivRem(remainder, (nuint)Vector512<T>.Count);
System\Numerics\Tensors\netcore\Tensor.Factory.cs (4)
128values[i] = T.CreateChecked(Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2));
System\Numerics\Tensors\netcore\TensorExtensions.cs (3)
3532return T.CreateChecked(Math.Sqrt(double.CreateChecked(variance))); 6844intermediateShape[^i] = Math.Max(intermediateShape[^i], shape1[^i]); 6848intermediateShape[^i] = Math.Max(intermediateShape[^i], shape2[^i]);
System\Numerics\Tensors\netcore\TensorHelpers.cs (2)
74int newShapeIndex = Math.Max(shape1.Length, shape2Length) - 1; 75nint[] newShape = new nint[Math.Max(shape1.Length, shape2Length)];
System\Numerics\Tensors\netcore\TensorSpanHelpers.cs (2)
227(nint Quotient, nint Remainder) result = Math.DivRem(curIndexes[curIndex], length[curIndex]); 247(nint Quotient, nint Remainder) result = Math.DivRem(curIndexes[curIndex], shape[curIndex]);
System\Numerics\Tensors\netcore\TensorSpanHelpers.T.cs (2)
35nuint toClear = Math.Min(len, int.MaxValue); 46nuint toFill = Math.Min(numElements, int.MaxValue);
System.Private.CoreLib (531)
src\libraries\Common\src\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs (1)
111int newSegmentSize = Math.Min(_tail._array.Length * 2, MaxSegmentSize);
src\libraries\Common\src\System\Collections\Generic\ArrayBuilder.cs (2)
148nextCapacity = Math.Max(capacity + 1, Array.MaxLength); 151nextCapacity = Math.Max(nextCapacity, minimum);
src\libraries\Common\src\System\Number.Formatting.Common.cs (1)
843int zeroes = Math.Min(-digPos, nMaxDigits);
src\libraries\Common\src\System\Number.Parsing.Common.cs (1)
227numberOfTrailingZeros = Math.Min(numberOfTrailingZeros, numberOfFractionalDigits);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Array.cs (1)
65(uint)Math.Min(newSize, larray.Length));
src\libraries\System.Private.CoreLib\src\System\Buffers\SharedArrayPool.cs (1)
508return Math.Min(partitionCount, Environment.ProcessorCount);
src\libraries\System.Private.CoreLib\src\System\Buffers\StandardFormat.cs (1)
182(div, precision) = Math.DivRem(precision, 10);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Base64Helper\Base64DecoderHelper.cs (1)
569int BlockSize = Math.Min(source.Length - (int)sourceIndex, 4);
src\libraries\System.Private.CoreLib\src\System\Buffers\Text\Utf8Parser\Utf8Parser.Number.cs (2)
113int numNonLeadingDigitsBeforeDecimalToCopy = Math.Min(numNonLeadingDigitsBeforeDecimal, maxDigitCount); 177int numDigitsAfterDecimalToCopy = Math.Min(srcIndex - startIndexOfDigitsAfterDecimalToCopy, maxDigitCount - dstIndex);
src\libraries\System.Private.CoreLib\src\System\Byte.cs (4)
279public static (byte Quotient, byte Remainder) DivRem(byte left, byte right) => Math.DivRem(left, right); 525public static byte Clamp(byte value, byte min, byte max) => Math.Clamp(value, min, max); 531public static byte Max(byte x, byte y) => Math.Max(x, y); 537public static byte Min(byte x, byte y) => Math.Min(x, y);
src\libraries\System.Private.CoreLib\src\System\Char.cs (4)
1491static char INumberBase<char>.MaxMagnitude(char x, char y) => (char)Math.Max(x, y); 1494static char INumberBase<char>.MaxMagnitudeNumber(char x, char y) => (char)Math.Max(x, y); 1497static char INumberBase<char>.MinMagnitude(char x, char y) => (char)Math.Min(x, y); 1500static char INumberBase<char>.MinMagnitudeNumber(char x, char y) => (char)Math.Min(x, y);
src\libraries\System.Private.CoreLib\src\System\CodeDom\Compiler\IndentedTextWriter.cs (1)
45set { _indentLevel = Math.Max(value, 0); }
src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueue.cs (2)
97length = (int)Math.Min(BitOperations.RoundUpToPowerOf2((uint)count), MaxSegmentLength); 645int nextSize = tail._preservedForObservation ? InitialSegmentLength : Math.Min(tail.Capacity * 2, MaxSegmentLength);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\Queue.cs (2)
112int firstPart = Math.Min(_array.Length - _head, numToCopy); 409newcapacity = Math.Max(newcapacity, _array.Length + MinimumGrow);
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
183int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 193nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\libraries\System.Private.CoreLib\src\System\Collections\HashHelpers.cs (1)
44int limit = (int)Math.Sqrt(candidate);
src\libraries\System.Private.CoreLib\src\System\Convert.cs (4)
1305return checked((long)Math.Round(value)); 1422return checked((ulong)Math.Round(value)); 2620(uint newLines, uint remainder) = Math.DivRem(outlen, Base64LineBreakPosition); 2992(int quotient, int remainder) = Math.DivRem(source.Length, 2);
src\libraries\System.Private.CoreLib\src\System\DateTime.cs (7)
872if (Math.Abs(value) > maxUnitCount) 877double integralPart = Math.Truncate(value); 1371(uint y100, uint r1) = Math.DivRem(((uint)(UTicks / TicksPer6Hours) | 3U) + 1224, DaysPer400Years); 1372ulong u2 = Math.BigMul(EafMultiplier, r1 | 3U); 1434ulong u2 = Math.BigMul(EafMultiplier, r1 | 3U); 1511ulong u2 = Math.BigMul(EafMultiplier, r1 | 3U); 1570(uint y100, uint r1) = Math.DivRem(((uint)(UTicks / TicksPer6Hours) | 3U), DaysPer400Years);
src\libraries\System.Private.CoreLib\src\System\Decimal.cs (1)
1265public static decimal Clamp(decimal value, decimal min, decimal max) => Math.Clamp(value, min, max);
src\libraries\System.Private.CoreLib\src\System\Decimal.DecCalc.cs (63)
182ulong high = Math.BigMul(a, b, out ulong low); 334(ulong quo64, bufNum.Low64) = Math.DivRem(num, den); 376ulong prod = Math.BigMul(quo, (uint)den); // quo * lo divisor 422ulong prod1 = Math.BigMul(quo, bufDen.U0); // quo * lo divisor 423ulong prod2 = Math.BigMul(quo, bufDen.U1); // quo * mid divisor 482ulong tmp = Math.BigMul(bufNum.U0, power); 485tmp += Math.BigMul(bufNum.U1, power); 488tmp += Math.BigMul(bufNum.U2, power); 495ulong tmp = Math.BigMul(bufNum.U0, power); 498tmp += Math.BigMul(bufNum.U1, power); 674(quotient, remainder) = Math.DivRem(high, power); 914low64 = Math.BigMul((uint)low64, UInt32Powers10[scale]); 918low64 = Math.BigMul((uint)low64, TenToPowerNine); 927tmpLow = Math.BigMul((uint)low64, power); 928tmp64 = Math.BigMul((uint)(low64 >> 32), power) + (tmpLow >> 32); 943tmpLow = Math.BigMul((uint)low64, power); 944tmp64 = Math.BigMul((uint)(low64 >> 32), power) + (tmpLow >> 32); 947tmp64 += Math.BigMul(high, power); 979tmp64 += Math.BigMul(rgulNum[cur], power); 1182ulong high = Math.BigMul(pwr, pdecIn.Mid); 1185ulong low = Math.BigMul(pwr, pdecIn.Low); 1270ulong tmpLow = Math.BigMul((uint)low64, power); 1271ulong tmp = Math.BigMul((uint)(low64 >> 32), power) + (tmpLow >> 32); 1274tmp += Math.BigMul(high, power); 1317ulong low64 = Math.BigMul(d1.Low, d2.Low); 1330(low64, ulong remainder) = Math.DivRem(low64, power); 1348tmp = Math.BigMul(d1.Low, d2.Low); 1351tmp = Math.BigMul(d1.Low, d2.Mid) + (tmp >> 32); 1357tmp += Math.BigMul(d1.Low, d2.High); 1372tmp = Math.BigMul(d2.Low, d1.Low); 1375tmp = Math.BigMul(d2.Low, d1.Mid) + (tmp >> 32); 1381tmp += Math.BigMul(d2.Low, d1.High); 1416tmp = Math.BigMul(d1.Low, d2.Low); 1419ulong tmp2 = Math.BigMul(d1.Low, d2.Mid) + (tmp >> 32); 1421tmp = Math.BigMul(d1.Mid, d2.Low); 1429tmp = Math.BigMul(d1.Mid, d2.Mid) + tmp2; 1435tmp2 = Math.BigMul(d1.Low, d2.High); 1441tmp2 = Math.BigMul(d1.High, d2.Low); 1448tmp = Math.BigMul(d1.Mid, d2.High); 1454tmp2 = Math.BigMul(d1.High, d2.Mid); 1461bufProd.High64 = Math.BigMul(d1.High, d2.High) + tmp; 1565mant = (uint)(int)Math.Round(dbl); 1584result.Low64 = Math.BigMul(mant, UInt32Powers10[power]); 1592ulong low64 = Math.BigMul(mant, UInt32Powers10[power - 18]); 1597ulong low64 = Math.BigMul(mant, UInt32Powers10[power - 9]); 1598ulong hi64 = Math.BigMul(TenToPowerNine, (uint)(low64 >> 32)); 1599low64 = Math.BigMul(TenToPowerNine, (uint)low64); 1624(uint div, uint rem) = Math.DivRem(mant, 10000); 1635(uint div, uint rem) = Math.DivRem(mant, 100); 1646(uint div, uint rem) = Math.DivRem(mant, 10); 1729mant = (ulong)(long)Math.Round(dbl); 1749ulong low64 = Math.BigMul((uint)mant, pow10); 1750ulong hi64 = Math.BigMul((uint)(mant >> 32), pow10); 1910curScale = Math.Min(9, -scale); 1954ulong num = Math.BigMul(remainder, power); 2005curScale = Math.Min(9, -scale); 2067curScale = Math.Min(9, -scale); 2187ulong tmp = Math.BigMul(d2.Low, power); 2214ulong tmp = Math.BigMul(bufQuo.U0, power); 2275ulong tmp64 = Math.BigMul(b.Buf24.U0, power); 2280tmp64 += Math.BigMul(buf[i], power); 2364(d.uhi, remainder) = Math.DivRem(n, divisor); 2405(d.uhi, remainder) = Math.DivRem(n, power);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\CounterGroup.cs (3)
267_nextPollingTimeStamp += TimeSpan.FromMilliseconds(_pollingIntervalInMilliseconds * Math.Ceiling(delta.TotalMilliseconds / _pollingIntervalInMilliseconds)); 304millisecondsTillNextPoll = Math.Max(1, millisecondsTillNextPoll); 305sleepDurationInMilliseconds = Math.Min(sleepDurationInMilliseconds, millisecondsTillNextPoll);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventCounter.cs (1)
108payload.StandardDeviation = Math.Sqrt(_sumSquared / _count - _sum * _sum / _count / _count);
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventSource.cs (4)
2089int paramCount = Math.Min(eventTypes.typeInfos.Length, args.Length); // parameter count mismatch get logged in LogEventArgsMismatches 2150args = new object?[Math.Min(eventDataCount, metadata.Parameters.Length)]; 2945dataDescrs[1].Size = (uint)Math.Min(dataLeft, chunkSize); 3505EventMetadata[] newValues = new EventMetadata[Math.Max(eventData.Length + 16, eventAttribute.EventId + 1)];
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\NameInfo.cs (1)
26newIdentity = Math.Max(newIdentity, snapshot); // Should be redundant. as we only create descriptors once.
src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\XplatEventLogger.cs (1)
90eventDataCount = Math.Min(payloadName.Count, payload.Count);
src\libraries\System.Private.CoreLib\src\System\Double.cs (57)
67public const double E = Math.E; 71public const double Pi = Math.PI; 75public const double Tau = Math.Tau; 579public static double Log2(double value) => Math.Log2(value); 633public static double Exp(double x) => Math.Exp(x); 636public static double ExpM1(double x) => Math.Exp(x) - 1; 639public static double Exp2(double x) => Math.Pow(2, x); 642public static double Exp2M1(double x) => Math.Pow(2, x) - 1; 645public static double Exp10(double x) => Math.Pow(10, x); 648public static double Exp10M1(double x) => Math.Pow(10, x) - 1; 656public static double Ceiling(double x) => Math.Ceiling(x); 682public static double Floor(double x) => Math.Floor(x); 686public static double Round(double x) => Math.Round(x); 689public static double Round(double x, int digits) => Math.Round(x, digits); 692public static double Round(double x, MidpointRounding mode) => Math.Round(x, mode); 695public static double Round(double x, int digits, MidpointRounding mode) => Math.Round(x, digits, mode); 699public static double Truncate(double x) => Math.Truncate(x); 782static double IFloatingPointConstants<double>.E => Math.E; 811public static double Atan2(double y, double x) => Math.Atan2(y, x); 817public static double BitDecrement(double x) => Math.BitDecrement(x); 820public static double BitIncrement(double x) => Math.BitIncrement(x); 824public static double FusedMultiplyAdd(double left, double right, double addend) => Math.FusedMultiplyAdd(left, right, addend); 827public static double Ieee754Remainder(double left, double right) => Math.IEEERemainder(left, right); 830public static int ILogB(double x) => Math.ILogB(x); 837public static double ReciprocalEstimate(double x) => Math.ReciprocalEstimate(x); 841public static double ReciprocalSqrtEstimate(double x) => Math.ReciprocalSqrtEstimate(x); 844public static double ScaleB(double x, int n) => Math.ScaleB(x, n); 855public static double Acosh(double x) => Math.Acosh(x); 859public static double Asinh(double x) => Math.Asinh(x); 863public static double Atanh(double x) => Math.Atanh(x); 867public static double Cosh(double x) => Math.Cosh(x); 871public static double Sinh(double x) => Math.Sinh(x); 875public static double Tanh(double x) => Math.Tanh(x); 890public static double Log(double x) => Math.Log(x); 893public static double Log(double x, double newBase) => Math.Log(x, newBase); 896public static double LogP1(double x) => Math.Log(x + 1); 899public static double Log2P1(double x) => Math.Log2(x + 1); 903public static double Log10(double x) => Math.Log10(x); 906public static double Log10P1(double x) => Math.Log10(x + 1); 944public static double Clamp(double value, double min, double max) => Math.Clamp(value, min, max); 947public static double CopySign(double value, double sign) => Math.CopySign(value, sign); 951public static double Max(double x, double y) => Math.Max(x, y); 978public static double Min(double x, double y) => Math.Min(x, y); 1004public static int Sign(double value) => Math.Sign(value); 1021public static double Abs(double value) => Math.Abs(value); 1117public static double MaxMagnitude(double x, double y) => Math.MaxMagnitude(x, y); 1147public static double MinMagnitude(double x, double y) => Math.MinMagnitude(x, y); 1453public static double Pow(double x, double y) => Math.Pow(x, y); 1461public static double Cbrt(double x) => Math.Cbrt(x); 1745public static double Sqrt(double x) => Math.Sqrt(x); 1777public static double Acos(double x) => Math.Acos(x); 1787public static double Asin(double x) => Math.Asin(x); 1797public static double Atan(double x) => Math.Atan(x); 1807public static double Cos(double x) => Math.Cos(x); 1918public static double Sin(double x) => Math.Sin(x); 1921public static (double Sin, double Cos) SinCos(double x) => Math.SinCos(x); 2126public static double Tan(double x) => Math.Tan(x);
src\libraries\System.Private.CoreLib\src\System\Environment.UnixOrBrowser.cs (2)
90ulong userTime100Nanoseconds = Math.Min(cpuInfo.lastRecordedUserTime / 100, (ulong)long.MaxValue); 91ulong kernelTime100Nanoseconds = Math.Min(cpuInfo.lastRecordedKernelTime / 100, (ulong)long.MaxValue);
src\libraries\System.Private.CoreLib\src\System\Globalization\CalendarData.Icu.cs (1)
346occurrences = Math.Max(occurrences, 3);
src\libraries\System.Private.CoreLib\src\System\Globalization\CalendricalCalculationsHelper.cs (16)
36return degree * Math.PI / 180; 41return Math.Sin(RadiansFromDegrees(degree)); 46return Math.Cos(RadiansFromDegrees(degree)); 51return Math.Tan(RadiansFromDegrees(degree)); 66return new DateTime(Math.Min((long)(Math.Floor(numberOfDays) * TimeSpan.TicksPerDay), DateTime.MaxValue.Ticks)).Year; 105double whole = Math.Floor(divisor / dividend); 150return ((Math.Pow(x, 2) / 41048480) - 15) / TimeSpan.SecondsPerDay; 239- (0.5 * Math.Pow(y, 2) * SinOfDegree(4 * lambda)) 240- (1.25 * Math.Pow(eccentricity, 2) * SinOfDegree(2 * anomaly))); 241const double Divisor = 2 * Math.PI; 246return Math.CopySign(Math.Min(Math.Abs(equation), TwelveHours), equation); 365return Math.Min(time, timeSunLastAtLongitude - (MeanSpeedOfSun * longitudeErrorDelta)); 376long lowerBoundNewYearDay = (long)Math.Floor(approx) - 1;
src\libraries\System.Private.CoreLib\src\System\Globalization\CompareInfo.Icu.cs (4)
350int length = Math.Min(source.Length, prefix.Length); 432int length = Math.Min(source.Length, prefix.Length); 534int length = Math.Min(source.Length, suffix.Length); 617int length = Math.Min(source.Length, suffix.Length);
src\libraries\System.Private.CoreLib\src\System\Globalization\CultureData.Icu.cs (1)
76int length = Math.Min(WINDOWS_MAX_COLLATION_NAME_LENGTH, endOfCollation - collationIndex); // Windows doesn't allow collation names longer than 8 characters
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeFormat.cs (8)
464FormatDigits(ref result, hour12, Math.Min(tokenLen, 2)); 469FormatDigits(ref result, dateTime.Hour, Math.Min(tokenLen, 2)); 474FormatDigits(ref result, dateTime.Minute, Math.Min(tokenLen, 2)); 479FormatDigits(ref result, dateTime.Second, Math.Min(tokenLen, 2)); 638FormatDigits(ref result, year, Math.Min(tokenLen, 2)); 824(int tens, int ones) = Math.DivRem(offset.Hours, 10); 1499(int offsetHours, int offsetMinutes) = Math.DivRem(offsetTotalMinutes, 60); 1703(int offsetHours, offsetMinutes) = Math.DivRem(offsetMinutes, 60);
src\libraries\System.Private.CoreLib\src\System\Globalization\DateTimeParse.cs (4)
2697if (!time.TryAddTicks((long)Math.Round(raw.fraction * TimeSpan.TicksPerSecond), out time)) 3058if (!time.TryAddTicks((long)Math.Round(partSecond * TimeSpan.TicksPerSecond), out time)) 4726if (!result.parsedDate.TryAddTicks((long)Math.Round(result.fraction * TimeSpan.TicksPerSecond), out result.parsedDate)) 5071if (!dateTime.TryAddTicks((long)Math.Round(fraction * TimeSpan.TicksPerSecond), out result.parsedDate))
src\libraries\System.Private.CoreLib\src\System\Globalization\IdnMapping.Icu.cs (1)
22int estimatedLength = (int)Math.Min(count * 3L + 4, StackallocThreshold);
src\libraries\System.Private.CoreLib\src\System\Globalization\InvariantModeCasing.cs (1)
185int length = Math.Min(lengthA, lengthB);
src\libraries\System.Private.CoreLib\src\System\Globalization\Normalization.Nls.cs (1)
79realLength = Math.Abs(realLength);
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.cs (1)
18int length = Math.Min(lengthA, lengthB);
src\libraries\System.Private.CoreLib\src\System\Globalization\Ordinal.Utf8.cs (6)
23int length = Math.Min(lengthA, lengthB); 111nuint lengthU = Math.Min((uint)lengthA, (uint)lengthB); 176int length = Math.Min(lengthA, lengthB); 336int length = Math.Min(sourceLength, prefixLength); 421nuint lengthU = Math.Min((uint)sourceLength, (uint)prefixLength); 486int length = Math.Min(sourceLength, prefixLength);
src\libraries\System.Private.CoreLib\src\System\Globalization\OrdinalCasing.Icu.cs (1)
191int length = Math.Min(lengthA, lengthB);
src\libraries\System.Private.CoreLib\src\System\Globalization\PersianCalendar.cs (2)
154int y = (int)(Math.Floor(((yearStart - s_persianEpoch) / CalendricalCalculationsHelper.MeanTropicalYearInDays) + 0.5)) + 1; 204year = (int)(Math.Floor(((yearStart - s_persianEpoch) / CalendricalCalculationsHelper.MeanTropicalYearInDays) + 0.5)) + 1;
src\libraries\System.Private.CoreLib\src\System\Globalization\TimeSpanFormat.cs (4)
137(totalSecondsRemaining, fraction64) = Math.DivRem((ulong)ticks, TimeSpan.TicksPerSecond); 181(totalMinutesRemaining, seconds) = Math.DivRem(totalSecondsRemaining, 60 /* seconds per minute */); 189(totalHoursRemaining, minutes) = Math.DivRem(totalMinutesRemaining, 60 /* minutes per hour */); 200(days, hours) = Math.DivRem((uint)totalHoursRemaining, 24 /* hours per day */);
src\libraries\System.Private.CoreLib\src\System\Half.cs (1)
1644public static Half Clamp(Half value, Half min, Half max) => (Half)Math.Clamp((float)value, (float)min, (float)max);
src\libraries\System.Private.CoreLib\src\System\Int16.cs (7)
282public static (short Quotient, short Remainder) DivRem(short left, short right) => Math.DivRem(left, right); 619public static short Clamp(short value, short min, short max) => Math.Clamp(value, min, max); 635Math.ThrowNegateTwosCompOverflow(); 645public static short Max(short x, short y) => Math.Max(x, y); 651public static short Min(short x, short y) => Math.Min(x, y); 657public static int Sign(short value) => Math.Sign(value); 673public static short Abs(short value) => Math.Abs(value);
src\libraries\System.Private.CoreLib\src\System\Int32.cs (8)
54public static long BigMul(int left, int right) => Math.BigMul(left, right); 297public static (int Quotient, int Remainder) DivRem(int left, int right) => Math.DivRem(left, right); 660public static int Clamp(int value, int min, int max) => Math.Clamp(value, min, max); 676Math.ThrowNegateTwosCompOverflow(); 686public static int Max(int x, int y) => Math.Max(x, y); 692public static int Min(int x, int y) => Math.Min(x, y); 698public static int Sign(int value) => Math.Sign(value); 714public static int Abs(int value) => Math.Abs(value);
src\libraries\System.Private.CoreLib\src\System\Int64.cs (8)
54public static Int128 BigMul(long left, long right) => Math.BigMul(left, right); 294public static (long Quotient, long Remainder) DivRem(long left, long right) => Math.DivRem(left, right); 657public static long Clamp(long value, long min, long max) => Math.Clamp(value, min, max); 673Math.ThrowNegateTwosCompOverflow(); 683public static long Max(long x, long y) => Math.Max(x, y); 689public static long Min(long x, long y) => Math.Min(x, y); 695public static int Sign(long value) => Math.Sign(value); 711public static long Abs(long value) => Math.Abs(value);
src\libraries\System.Private.CoreLib\src\System\IntPtr.cs (7)
299public static (nint Quotient, nint Remainder) DivRem(nint left, nint right) => Math.DivRem(left, right); 652public static nint Clamp(nint value, nint min, nint max) => Math.Clamp(value, min, max); 668Math.ThrowNegateTwosCompOverflow(); 678public static nint Max(nint x, nint y) => Math.Max(x, y); 684public static nint Min(nint x, nint y) => Math.Min(x, y); 690public static int Sign(nint value) => Math.Sign(value); 706public static nint Abs(nint value) => Math.Abs(value);
src\libraries\System.Private.CoreLib\src\System\IO\BinaryReader.cs (2)
265int readLength = Math.Min(MaxCharBytesSize, stringLength - currPos); 286sb ??= StringBuilderCache.Acquire(Math.Min(stringLength, StringBuilderCache.MaxBuilderSize)); // Actual string length in chars may be smaller.
src\libraries\System.Private.CoreLib\src\System\IO\BufferedStream.cs (4)
124byte[] shadowBuffer = new byte[Math.Min(_bufferSize + _bufferSize, MaxShadowBufferSize)]; 448int readbytes = Math.Min(_readLen - _readPos, destination.Length); 768int bytesToWrite = Math.Min(_bufferSize - _writePos, count); 783int bytesToWrite = Math.Min(_bufferSize - _writePos, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\File.cs (6)
1227newLength = (uint)Math.Max(Array.MaxLength, rentedArray.Length + 1); 1469newLength = (uint)Math.Max(Array.MaxLength, buffer.Length + 1); 1518int bytesNeeded = preambleSize + encoding.GetMaxByteCount(Math.Min(contents.Length, ChunkSize)); 1536ReadOnlySpan<char> toEncode = contents.Slice(0, Math.Min(contents.Length, ChunkSize)); 1574byte[] bytes = ArrayPool<byte>.Shared.Rent(preambleSize + encoding.GetMaxByteCount(Math.Min(contents.Length, ChunkSize))); 1590ReadOnlyMemory<char> toEncode = contents.Slice(0, Math.Min(contents.Length, ChunkSize));
src\libraries\System.Private.CoreLib\src\System\IO\MemoryStream.cs (3)
137int newCapacity = Math.Max(value, 256); 150newCapacity = Math.Max(value, Array.MaxLength); 357int n = Math.Min(_length - _position, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\Path.cs (1)
908sb.EnsureCapacity(Math.Max(relativeTo.Length, path.Length));
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\BufferedFileStreamStrategy.cs (3)
373int n = Math.Min(_readLen - _readPos, destination.Length); 407bytesFromBuffer = Math.Min(buffer.Length, _readLen - _readPos); 447bytesFromBuffer = Math.Min(_readLen, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\IO\Stream.cs (1)
148bufferSize = (int)Math.Min(bufferSize, remaining);
src\libraries\System.Private.CoreLib\src\System\IO\StreamReader.cs (1)
554int len = Math.Min(_byteLen, preamble.Length);
src\libraries\System.Private.CoreLib\src\System\IO\StreamWriter.cs (2)
438int n = Math.Min(charBuffer.Length - dstPos, count); 789int n = Math.Min(_charLen - _charPos, source.Length - copied);
src\libraries\System.Private.CoreLib\src\System\IO\UnmanagedMemoryStream.cs (1)
371long n = Math.Min(len - pos, buffer.Length);
src\libraries\System.Private.CoreLib\src\System\MathF.cs (4)
49return Math.Abs(x); 248return Math.Max(x, y); 280return Math.Min(x, y); 449return Math.Sign(x);
src\libraries\System.Private.CoreLib\src\System\MemoryExtensions.cs (1)
3270nuint length = Math.Min((nuint)(uint)span.Length, (nuint)(uint)other.Length);
src\libraries\System.Private.CoreLib\src\System\Number.BigInteger.cs (2)
465(uint quotient, uint remainder) = Math.DivRem(lhs._blocks[0], rhs._blocks[0]); 484(digit, carry) = Math.DivRem(value, rhsValue);
src\libraries\System.Private.CoreLib\src\System\Number.Dragon4.cs (1)
177int digitExponent = (int)(Math.Ceiling(((int)(mantissaHighBitIdx) + exponent) * Log10V2 - 0.69));
src\libraries\System.Private.CoreLib\src\System\Number.Formatting.cs (34)
605nMaxDigits = Math.Max(number.DigitsCount, TNumber.MaxRoundTripDigits); 1391int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((uint)(-value))) + sNegative.Length; 1417int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((uint)(-value))) + sNegative.Length; 1446int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((uint)value)); 1465int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((uint)value)); 1502int bufferLength = Math.Max(digits, 32 - (int)uint.LeadingZeroCount(value)); 1521int bufferLength = Math.Max(digits, 32 - (int)uint.LeadingZeroCount(value)); 1596(value, uint remainder) = Math.DivRem(value, 100); 1638(value, uint remainder) = Math.DivRem(value, 100); 1666(value, remainder) = Math.DivRem(value, 100); 1673(value, remainder) = Math.DivRem(value, 10); 1720int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value)); 1756int bufferLength = Math.Max(digits, countedDigits); 1824int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((ulong)(-value))) + sNegative.Length; 1850int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits((ulong)(-value))) + sNegative.Length; 1879int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((ulong)value)); 1898int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits((ulong)value)); 1951int bufferLength = Math.Max(digits, 64 - (int)ulong.LeadingZeroCount(value)); 1970int bufferLength = Math.Max(digits, 64 - (int)ulong.LeadingZeroCount(value)); 2067(value, ulong remainder) = Math.DivRem(value, 100); 2106(value, remainder) = Math.DivRem(value, 100); 2113(value, remainder) = Math.DivRem(value, 10); 2148int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value)); 2183int bufferLength = Math.Max(digits, countedDigits); 2252int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(absValue)) + sNegative.Length; 2280int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(absValue)) + sNegative.Length; 2311int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits(uValue)); 2332int bufferLength = Math.Max(digits, FormattingHelpers.CountHexDigits(uValue)); 2361return Int64ToHexChars(buffer, lower, hexBase, Math.Max(digits, 1)); 2374int bufferLength = Math.Max(digits, 128 - (int)UInt128.LeadingZeroCount((UInt128)value)); 2395int bufferLength = Math.Max(digits, 128 - (int)UInt128.LeadingZeroCount((UInt128)value)); 2424return UInt64ToBinaryChars(buffer, lower, Math.Max(digits, 1)); 2510int bufferLength = Math.Max(digits, FormattingHelpers.CountDigits(value)); 2524int bufferLength = Math.Max(digits, countedDigits);
src\libraries\System.Private.CoreLib\src\System\Number.Grisu3.cs (3)
561(digit, integrals) = Math.DivRem(integrals, divisor); 740(digit, integrals) = Math.DivRem(integrals, divisor); 823double k = Math.Ceiling((minExponent + DiyFp.SignificandSize - 1) * D1Log210);
src\libraries\System.Private.CoreLib\src\System\Number.NumberToFloatingPointBits.cs (7)
708uint count = Math.Min(remaining, 9); 849(uint topBlockIndex, uint topBlockBits) = Math.DivRem(integerBitsOfPrecision, 32); 993uint positiveExponent = (uint)(Math.Max(0, number.Scale)); 995uint integerDigitsPresent = Math.Min(positiveExponent, totalDigits); 1006int fastExponent = Math.Abs(exponent); 1395ulong high = Math.BigMul(w, Pow5128Table[index], out ulong low); 1401ulong high2 = Math.BigMul(w, Pow5128Table[index + 1], out ulong _);
src\libraries\System.Private.CoreLib\src\System\Number.Parsing.cs (1)
748value = new decimal(0, 0, 0, sign, (byte)Math.Clamp(-e, 0, 28));
src\libraries\System.Private.CoreLib\src\System\Numerics\INumber.cs (1)
29Math.ThrowMinMaxException(min, max);
src\libraries\System.Private.CoreLib\src\System\Random.CompatImpl.cs (1)
264int subtraction = (seed == int.MinValue) ? int.MaxValue : Math.Abs(seed);
src\libraries\System.Private.CoreLib\src\System\Random.ImplBase.cs (2)
61ulong randomProduct = Math.BigMul(maxValue, xoshiro.NextUInt64(), out ulong lowPart); 69randomProduct = Math.BigMul(maxValue, xoshiro.NextUInt64(), out lowPart);
src\libraries\System.Private.CoreLib\src\System\Reflection\AssemblyName.cs (1)
348short maxSize = (short)Math.Min(end - i, (int)c_MaxUnicodeCharsReallocate - 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\DefaultInterpolatedStringHandler.cs (4)
96Math.Max(MinimumArrayPoolLength, literalLength + (formattedCount * GuessedLengthPerHole)); 631uint newCapacity = Math.Max(requiredMinCapacity, Math.Min((uint)_chars.Length * 2, string.MaxLength)); 632int arraySize = (int)Math.Clamp(newCapacity, MinimumArrayPoolLength, int.MaxValue);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ArrayMarshaller.cs (2)
42int spaceToAllocate = Math.Max(checked(sizeof(TUnmanagedElement) * numElements), 1); 148int spaceToAllocate = Math.Max(bufferSize, 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\PointerArrayMarshaller.cs (2)
43int spaceToAllocate = Math.Max(checked(sizeof(TUnmanagedElement) * numElements), 1); 149int spaceToAllocate = Math.Max(bufferSize, 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\ReadOnlySpanMarshaller.cs (1)
53int spaceToAllocate = Math.Max(checked(sizeof(TUnmanagedElement) * numElements), 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\Marshalling\SpanMarshaller.cs (1)
47int spaceToAllocate = Math.Max(checked(sizeof(TUnmanagedElement) * numElements), 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\NativeMemory.Unix.cs (2)
43nuint adjustedAlignment = Math.Max(alignment, (uint)sizeof(void*)); 104nuint adjustedAlignment = Math.Max(alignment, (uint)sizeof(void*));
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Scalar.cs (13)
145return (T)(object)Math.Abs((double)(object)value); 194return (T)(object)Math.Abs((float)(object)value); 266return (T)(object)Math.Ceiling((double)(object)value); 578return (T)(object)Math.Floor((double)(object)value); 1267return (T)(object)Math.Round((double)(object)value); 1475return (T)(object)(double)Math.Sqrt((double)(object)value); 1483return (T)(object)(int)Math.Sqrt((int)(object)value); 1487return (T)(object)(long)Math.Sqrt((long)(object)value); 1491return (T)(object)(nint)Math.Sqrt((nint)(object)value); 1495return (T)(object)(nuint)Math.Sqrt((nuint)(object)value); 1511return (T)(object)(uint)Math.Sqrt((uint)(object)value); 1515return (T)(object)(ulong)Math.Sqrt((ulong)(object)value); 1587return (T)(object)Math.Truncate((double)(object)value);
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector128.cs (2)
447/// <seealso cref="Math.Ceiling(double)" /> 1724/// <seealso cref="Math.Floor(double)" />
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector256.cs (2)
312/// <seealso cref="Math.Ceiling(double)" /> 1642/// <seealso cref="Math.Floor(double)" />
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector512.cs (2)
312/// <seealso cref="Math.Ceiling(double)" /> 1691/// <seealso cref="Math.Floor(double)" />
src\libraries\System.Private.CoreLib\src\System\Runtime\Intrinsics\Vector64.cs (2)
262/// <seealso cref="Math.Ceiling(double)" /> 1400/// <seealso cref="Math.Floor(double)" />
src\libraries\System.Private.CoreLib\src\System\Runtime\MemoryFailPoint.cs (2)
153ulong segmentSize = (ulong)(Math.Ceiling((double)size / s_GCSegmentSize) * s_GCSegmentSize); 157ulong requestedSizeRounded = (ulong)(Math.Ceiling((double)sizeInMegabytes / MemoryCheckGranularity) * MemoryCheckGranularity);
src\libraries\System.Private.CoreLib\src\System\SByte.cs (7)
285public static (sbyte Quotient, sbyte Remainder) DivRem(sbyte left, sbyte right) => Math.DivRem(left, right); 582public static sbyte Clamp(sbyte value, sbyte min, sbyte max) => Math.Clamp(value, min, max); 598Math.ThrowNegateTwosCompOverflow(); 608public static sbyte Max(sbyte x, sbyte y) => Math.Max(x, y); 614public static sbyte Min(sbyte x, sbyte y) => Math.Min(x, y); 620public static int Sign(sbyte value) => Math.Sign(value); 636public static sbyte Abs(sbyte value) => Math.Abs(value);
src\libraries\System.Private.CoreLib\src\System\SearchValues\SearchValues.cs (1)
114? new Any1CharPackedIgnoreCaseSearchValues((char)Math.Max(value0, value1))
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\AhoCorasickNode.cs (1)
145maxValue = Math.Max(maxValue, childChar);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\Helpers\RabinKarp.cs (1)
47minimumLength = Math.Min(minimumLength, value.Length);
src\libraries\System.Private.CoreLib\src\System\SearchValues\Strings\StringSearchValues.cs (1)
458minLength = Math.Min(minLength, value.Length);
src\libraries\System.Private.CoreLib\src\System\Security\SecureString.Unix.cs (1)
19return Math.Max(length, 1) * sizeof(char);
src\libraries\System.Private.CoreLib\src\System\Single.cs (1)
941public static float Clamp(float value, float min, float max) => Math.Clamp(value, min, max);
src\libraries\System.Private.CoreLib\src\System\SpanHelpers.T.cs (1)
1681char lowerCase = (char)Math.Max(char0, char1);
src\libraries\System.Private.CoreLib\src\System\String.Comparison.cs (9)
87int length = Math.Min(strA.Length, strB.Length); 323lengthA = Math.Min(lengthA, strA.Length - indexA); 328lengthB = Math.Min(lengthB, strB.Length - indexB); 358lengthA = Math.Min(lengthA, strA.Length - indexA); 363lengthB = Math.Min(lengthB, strB.Length - indexB); 403int lengthA = Math.Min(length, strA.Length - indexA); 404int lengthB = Math.Min(length, strB.Length - indexB); 484int lengthA = Math.Min(length, strA.Length - indexA); 485int lengthB = Math.Min(length, strB.Length - indexB);
src\libraries\System.Private.CoreLib\src\System\Text\ASCIIEncoding.cs (4)
375int bytesWritten = (int)Ascii.NarrowUtf16ToAscii(pChars, pBytes, (uint)Math.Min(charsLength, bytesLength)); 393int numElementsToConvert = Math.Min(chars.Length, bytes.Length); 666bytesConsumed = (int)Ascii.WidenAsciiToUtf16(pBytes, pChars, (uint)Math.Min(charsLength, bytesLength)); 681int numElementsToConvert = Math.Min(bytes.Length, chars.Length);
src\libraries\System.Private.CoreLib\src\System\Text\CompositeFormat.cs (1)
55argsRequired = Math.Max(argsRequired, segment.ArgIndex + 1);
src\libraries\System.Private.CoreLib\src\System\Text\Latin1Encoding.cs (2)
321int bytesWritten = (int)Latin1Utility.NarrowUtf16ToLatin1(pChars, pBytes, (uint)Math.Min(charsLength, bytesLength)); 621int charsWritten = Math.Min(bytesLength, charsLength);
src\libraries\System.Private.CoreLib\src\System\Text\StringBuilder.cs (17)
135capacity = Math.Max(capacity, length); 159capacity = Math.Min(DefaultCapacity, maxCapacity); 207persistedCapacity = Math.Min(Math.Max(DefaultCapacity, persistedString.Length), persistedMaxCapacity); 417int capacityToPreserve = Math.Min(Capacity, Math.Max(Length * 6 / 5, m_ChunkChars.Length)); 845int length = Math.Min(m_ChunkChars.Length - m_ChunkLength, count); 909chunkEndIndex = Math.Min(chunkEndIndex, chunk.m_ChunkLength); 2109ReadOnlySpan<char> remainingChunk = chunk.m_ChunkChars.AsSpan(indexInChunk, Math.Min(chunk.m_ChunkLength - indexInChunk, count)); 2145Debug.Assert(oldValue.Length > Math.Min(count, chunk.m_ChunkLength - indexInChunk), 2231int curInChunk = Math.Max(startIndexInChunk, 0); 2232int endInChunk = Math.Min(chunk.m_ChunkLength, endIndexInChunk); 2476int lengthToCopy = Math.Min(lengthInChunk, count); 2562int newBlockLength = Math.Max(minBlockCharCount, Math.Min(Length, MaxChunkSize)); 2670StringBuilder newChunk = new StringBuilder(Math.Max(count, DefaultCapacity), chunk.m_MaxCapacity, chunk.m_ChunkPrevious); 2674int copyCount1 = Math.Min(count, indexInChunk);
src\libraries\System.Private.CoreLib\src\System\Text\TranscodingStream.cs (4)
353int bytesToReturn = Math.Min(_readBufferCount, buffer.Length); 432int bytesToReturn = Math.Min(_readBufferCount, buffer.Length); 484int rentalLength = Math.Clamp(buffer.Length, MinWriteRentedArraySize, MaxWriteRentedArraySize); 560int rentalLength = Math.Clamp(remainingOuterEncodedBytes.Length, MinWriteRentedArraySize, MaxWriteRentedArraySize);
src\libraries\System.Private.CoreLib\src\System\Text\Unicode\Utf8Utility.Transcoding.cs (4)
30nuint numElementsConverted = Ascii.WidenAsciiToUtf16(pInputBuffer, pOutputBuffer, (uint)Math.Min(inputLength, outputCharsRemaining)); 95uint maxIters = Math.Min(remainingInputBytes, (uint)outputCharsRemaining) / (2 * sizeof(uint)); 851nuint numElementsConverted = Ascii.NarrowUtf16ToAscii(pInputBuffer, pOutputBuffer, (uint)Math.Min(inputLength, outputBytesRemaining)); 939uint minElementsRemaining = (uint)Math.Min(inputCharsRemaining, outputBytesRemaining);
src\libraries\System.Private.CoreLib\src\System\Threading\LowLevelLifoSemaphore.cs (1)
226(int)Math.Min(newCounts.SignalCount, (uint)counts.WaiterCount + counts.SpinnerCount) -
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); 249return Math.Min((uint)delayStepCount * BlockingConfig.DelayStepMs, BlockingConfig.MaxDelayMs); 327blocking_threadsPerDelayStep_procCountFactor = Math.Max(1, blocking_threadsPerDelayStep_procCountFactor); 337MaxDelayMs = Math.Max(1, Math.Min(MaxDelayMs, GateThread.GateActivitiesPeriodMs)); 338DelayStepMs = Math.Max(1, Math.Min(DelayStepMs, MaxDelayMs));
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.cs (6)
191_legacy_minIOCompletionThreads = (short)Math.Max(1, ioCompletionThreads); 193short newMinThreads = (short)Math.Max(1, workerThreads); 274_legacy_maxIOCompletionThreads = (short)Math.Min(ioCompletionThreads, MaxPossibleThreadCount); 276short newMaxThreads = (short)Math.Min(workerThreads, MaxPossibleThreadCount); 313workerThreads = Math.Max(0, _maxThreads - counts.NumProcessingWork); 478_memoryUsageBytes = Math.Min(gcMemoryInfo.MemoryLoadBytes, gcMemoryInfo.HighMemoryLoadThresholdBytes);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.GateThread.cs (1)
294uint nextDelay = Math.Min(nextDelayForGateActivities, nextDelayForBlockingAdjustment);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.HillClimbing.Complex.cs (1)
35public double Abs() => Math.Sqrt(Real * Real + Imaginary * Imaginary);
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); 377newSampleInterval = (int)(0.5 + _currentSampleMs * (10.0 * Math.Min(-ratio.Real, 1.0))); 413entry.lastHistoryCount = (int)(Math.Min(_totalSamples, _samplesToMeasure) / _wavePeriod) * _wavePeriod; 447double w = 2 * Math.PI / period; 448double cos = Math.Cos(w); 457return new Complex(q1 - q2 * cos, q2 * Math.Sin(w)) / numSamples;
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.ThreadCounts.cs (3)
43SetInt16Value(Math.Max((short)0, value), NumProcessingWorkShift); 61SetInt16Value(Math.Max((short)0, value), NumExistingThreadsShift); 79SetInt16Value(Math.Max((short)1, value), NumThreadsGoalShift);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.WaitThread.cs (2)
226int handleTimeoutDurationMs = Math.Max(0, registeredWait.TimeoutTimeMs - currentTimeMs); 234timeoutDurationMs = Math.Min(handleTimeoutDurationMs, timeoutDurationMs);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.WorkerThread.cs (3)
218Math.Max( 220Math.Min(newNumExistingThreads, counts.NumThreadsGoal)); 293newNumExistingThreads = Math.Max(numExistingThreads, newNumProcessingWork);
src\libraries\System.Private.CoreLib\src\System\Threading\ProcessorIdCache.cs (3)
94minID = Math.Min(minID, (double)t / iters); 111minTLS = Math.Min(minTLS, (double)t / iters); 136s_processorIdRefreshRate = Math.Min((int)(minID * 5 / minTLS), MaxIdRefreshRate);
src\libraries\System.Private.CoreLib\src\System\Threading\SemaphoreSlim.cs (1)
812int waitersToNotify = Math.Min(currentCount, waitCount) - m_countOfWaitersPulsedToWake;
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (1)
372return Math.Max(0, m_tailIndex - m_headIndex);
src\libraries\System.Private.CoreLib\src\System\Threading\Timer.cs (1)
125uint actualDuration = Math.Min(requestedDuration, maxPossibleDuration);
src\libraries\System.Private.CoreLib\src\System\Threading\WaitHandle.cs (2)
222safeWaitHandles = new SafeWaitHandle[Math.Max(capacity, 223Math.Min(MaxWaitHandles, 2 * currentLength))];
src\libraries\System.Private.CoreLib\src\System\TimeSpan.cs (17)
479Int128 totalMicroseconds = Math.BigMul(days, MicrosecondsPerDay) 480+ Math.BigMul(hours, MicrosecondsPerHour) 481+ Math.BigMul(minutes, MicrosecondsPerMinute) 482+ Math.BigMul(seconds, MicrosecondsPerSecond) 483+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond) 515Int128 totalMicroseconds = Math.BigMul(hours, MicrosecondsPerHour) 516+ Math.BigMul(minutes, MicrosecondsPerMinute) 517+ Math.BigMul(seconds, MicrosecondsPerSecond) 518+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond) 549Int128 totalMicroseconds = Math.BigMul(minutes, MicrosecondsPerMinute) 550+ Math.BigMul(seconds, MicrosecondsPerSecond) 551+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond) 581Int128 totalMicroseconds = Math.BigMul(seconds, MicrosecondsPerSecond) 582+ Math.BigMul(milliseconds, MicrosecondsPerMillisecond) 612Int128 totalMicroseconds = Math.BigMul(milliseconds, MicrosecondsPerMillisecond) 923double ticks = Math.Round(timeSpan.Ticks * factor); 938double ticks = Math.Round(timeSpan.Ticks / divisor);
src\libraries\System.Private.CoreLib\src\System\TimeZoneInfo.Unix.cs (2)
1209index += (int)Math.Min(t.IsStdCount, t.TypeCount); 1218index += (int)Math.Min(t.IsGmtCount, t.TypeCount);
src\libraries\System.Private.CoreLib\src\System\UInt16.cs (4)
276public static (ushort Quotient, ushort Remainder) DivRem(ushort left, ushort right) => Math.DivRem(left, right); 544public static ushort Clamp(ushort value, ushort min, ushort max) => Math.Clamp(value, min, max); 550public static ushort Max(ushort x, ushort y) => Math.Max(x, y); 556public static ushort Min(ushort x, ushort y) => Math.Min(x, y);
src\libraries\System.Private.CoreLib\src\System\UInt32.cs (5)
51public static ulong BigMul(uint left, uint right) => Math.BigMul(left, right); 292public static (uint Quotient, uint Remainder) DivRem(uint left, uint right) => Math.DivRem(left, right); 583public static uint Clamp(uint value, uint min, uint max) => Math.Clamp(value, min, max); 589public static uint Max(uint x, uint y) => Math.Max(x, y); 595public static uint Min(uint x, uint y) => Math.Min(x, y);
src\libraries\System.Private.CoreLib\src\System\UInt64.cs (5)
51public static UInt128 BigMul(ulong left, ulong right) => Math.BigMul(left, right); 291public static (ulong Quotient, ulong Remainder) DivRem(ulong left, ulong right) => Math.DivRem(left, right); 582public static ulong Clamp(ulong value, ulong min, ulong max) => Math.Clamp(value, min, max); 588public static ulong Max(ulong x, ulong y) => Math.Max(x, y); 594public static ulong Min(ulong x, ulong y) => Math.Min(x, y);
src\libraries\System.Private.CoreLib\src\System\UIntPtr.cs (4)
295public static (nuint Quotient, nuint Remainder) DivRem(nuint left, nuint right) => Math.DivRem(left, right); 585public static nuint Clamp(nuint value, nuint min, nuint max) => Math.Clamp(value, min, max); 591public static nuint Max(nuint x, nuint y) => Math.Max(x, y); 597public static nuint Min(nuint x, nuint y) => Math.Min(x, y);
src\System\Reflection\Emit\RuntimeILGenerator.cs (3)
90m_ILStream = new byte[Math.Max(size, DefaultSize)]; 261byte[] temp = new byte[Math.Max(m_ILStream.Length * 2, m_length + size)]; 333return (int)Math.Min(ushort.MaxValue, m_maxDepth + m_depthAdjustment);
src\System\RuntimeType.CoreCLR.cs (2)
574newSize = Math.Max(Math.Max(4, 2 * cachedMembers.Length), list.Length);
src\System\StubHelpers.cs (1)
451int numChars = Math.Min(managed.Length, length - 1);
System.Private.CoreLib.Generators (3)
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
183int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 193nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
System.Private.DataContractSerialization (52)
System\Runtime\Serialization\Json\JsonEncodingStreamWrapper.cs (1)
266int size = Math.Min(_chars.Length, buffer.Length);
System\Runtime\Serialization\Json\XmlJsonReader.cs (1)
755actual = Math.Min(count, value.Length);
System\Runtime\Serialization\SchemaExporter.cs (1)
459return isFlags ? (long)Math.Pow(2, index) : index;
System\Runtime\Serialization\XmlReaderDelegator.cs (1)
793return Math.Min(context.RemainingItemCount, dictionaryReader.Quotas.MaxArrayLength);
System\Xml\ArrayHelper.cs (1)
69count = Math.Min(count, 256);
System\Xml\EncodingStreamWrapper.cs (2)
312int max = offset + Math.Min(count, BufferLength); 470int inputCount = Math.Min(count, BufferLength * 2);
System\Xml\ValueHandle.cs (4)
663actual = Math.Min(_length, count); 673int charCount = Math.Min(count / 3 * 4, _length); 742actualByteCount = Math.Min(charCount, byteCount); 807int charCount = Math.Min(count, _length / sizeof(char));
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)
881int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0); 893int actual = Math.Max(maxLength - maxTextNodeLength, 0); 951int maxLength = Math.Max(_maxBytesPerRead - maxTextNodeLength, 0); 963int actual = Math.Max(maxLength - maxTextNodeLength, 0); 993int maxBytesPerRead = Math.Max(_maxBytesPerRead - nodeLength, 0); 1240int actual = Math.Min(count, _arrayCount); 1263int actual = Math.Min(count, _arrayCount); 1286int actual = Math.Min(count, _arrayCount); 1309int actual = Math.Min(count, _arrayCount); 1332int actual = Math.Min(count, _arrayCount); 1355int actual = Math.Min(count, _arrayCount); 1378int actual = Math.Min(count, _arrayCount); 1402int actual = Math.Min(count, _arrayCount); 1431int actual = Math.Min(count, _arrayCount); 1467int actual = Math.Min(count, _arrayCount);
System\Xml\XmlBinaryReaderSession.cs (3)
43_strings = new XmlDictionaryString[Math.Max(id + 1, 16)]; 47XmlDictionaryString[] newStrings = new XmlDictionaryString[Math.Min(Math.Max(id + 1, _strings.Length * 2), MaxArrayEntries)];
System\Xml\XmlBinaryWriterSession.cs (2)
64IntArray keys = new IntArray(Math.Max(minCount, 16)); 247int[] newArray = new int[Math.Max(index + 1, _array.Length * 2)];
System\Xml\XmlBufferReader.cs (7)
163TryEnsureBytes(Math.Min(count, _windowOffsetMax - offset)); 228byte[] newBuffer = new byte[Math.Max(256, _buffer.Length * 2)]; 230newOffsetMax = Math.Min(newOffsetMax, newBuffer.Length); 284_windowOffsetMax = Math.Max(windowOffset + windowLength, _offsetMax); 872int length = Math.Min(byteLength, charLength); 886int length = Math.Min(byteLength, charLength); 918int length = Math.Min(length1, length2);
System\Xml\XmlCanonicalWriter.cs (3)
346_xmlnsBuffer = new byte[Math.Max(byteCount, 128)]; 350byte[] newBuffer = new byte[Math.Max(_xmlnsOffset + byteCount, _xmlnsBuffer.Length * 2)]; 832int length = Math.Min(length1, length2);
System\Xml\XmlConverter.cs (2)
1071offset += ToCharsD2(Math.Abs(ts.Hours), chars, offset); 1073offset += ToCharsD2(Math.Abs(ts.Minutes), chars, offset);
System\Xml\XmlSigningNodeWriter.cs (1)
360int byteCount = Math.Min(_base64Chars.Length / 4 * 3, count - count % 3);
System\Xml\XmlUTF8TextWriter.cs (2)
654int byteCount = Math.Min(bufferLength / 4 * 3, count - count % 3); 673int byteCount = Math.Min(bufferLength / 4 * 3, count - count % 3);
System.Private.Uri (4)
src\libraries\Common\src\System\Collections\Generic\ArrayBuilder.cs (2)
148nextCapacity = Math.Max(capacity + 1, Array.MaxLength); 151nextCapacity = Math.Max(nextCapacity, minimum);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System.Private.Windows.Core (6)
System\Collections\Generic\ArrayBuilder.cs (2)
30_items = new T[Math.Min(expectedCount, MaxInitialArrayLength)]; 61int newCapacity = Math.Min(_maxCount, 2 * _items.Length);
System\IO\Compression\RunLengthEncoder.cs (1)
68if (!writer.TryWrite((byte)Math.Min(count, 0xFF)) || !writer.TryWrite(value))
System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
Windows\Win32\PInvoke.GetWindowText.cs (1)
39textLength = Math.Max(textLength, newTextLength);
System.Private.Xml (28)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Xml\Core\XmlReader.cs (1)
1712int bytesToRead = Math.Min(bytes.Length, 2);
System\Xml\Core\XmlTextReaderImpl.cs (1)
2885int bytesToRead = Math.Min(4, _ps.bytes.Length - _ps.bytesUsed);
System\Xml\Core\XmlTextReaderImplAsync.cs (1)
913int bytesToRead = Math.Min(4, _ps.bytes.Length - _ps.bytesUsed);
System\Xml\Core\XmlTextWriter.cs (1)
1450_textWriter.Write(_indentChars, 0, Math.Min(i, _indentChars.Length));
System\Xml\Dom\XmlCharacterData.cs (2)
143count = Math.Max(len - offset, 0); 169count = Math.Max(len - offset, 0);
System\Xml\Schema\BitSet.cs (1)
219int i = Math.Min(_bits.Length, other._bits.Length);
System\Xml\Serialization\ReflectionXmlSerializationWriter.cs (2)
1222for (int j = 0; j < Math.Min(pLength, mapping.Members.Length); j++) 1253for (int j = 0; j < Math.Min(pLength, mapping.Members.Length); j++)
System\Xml\Serialization\XmlSerializationReader.cs (2)
482currentSize = Math.Min(currentSize * 2, MAX_ALLOC_SIZE); 503currentSize = Math.Min(block.Length, total);
System\Xml\XmlConvert.cs (1)
1105double temp = Math.Round(value);
System\Xml\XPath\Internal\NumberFunctions.cs (2)
99return Math.Floor((double)_arg.Evaluate(nodeIterator)); 105return Math.Ceiling((double)_arg.Evaluate(nodeIterator));
System\Xml\Xsl\Runtime\NumberFormatter.cs (1)
82Debug.Assert(Math.Pow(totalChars, MaxAlphabeticLength) >= MaxAlphabeticValue);
System\Xml\Xsl\Runtime\XslNumber.cs (2)
308Debug.Assert(val >= 0 && val == Math.Round(val), "ConvertToArabic operates on non-negative integer numbers only"); 314int newLen = Math.Max(oldLen, minLen);
System\Xml\Xsl\Runtime\XsltFunctions.cs (1)
209double temp = Math.Round(value);
System\Xml\Xsl\Runtime\XsltLibrary.cs (3)
39public static readonly MethodInfo Floor = typeof(Math).GetMethod("Floor", new[] { typeof(double) })!; 40public static readonly MethodInfo Ceiling = typeof(Math).GetMethod("Ceiling", new[] { typeof(double) })!; 578idx += Math.Max(count - 4, 0);
System\Xml\Xsl\XPathConvert.cs (4)
745if (wExp2 >= 1023 && wExp2 <= 1075 && dbl == Math.Floor(dbl)) 992Debug.Assert(dblInt == Math.Floor(dblInt) && 1 <= dblInt && dblInt <= 9007199254740991.0d); 1020Debug.Assert(dblInt == Math.Floor(dblInt) && 0 <= dblInt && dblInt < C10toN[iT]); 1042(idx == mantissaSize - 1) && Math.Abs(mantissa[idx] - mantissaPrec[idx]) <= 1
System\Xml\Xsl\XsltOld\NumberAction.cs (1)
122if (Math.Floor(val) == val)
System.Reflection.Emit (3)
System\Reflection\Emit\ILGeneratorImpl.cs (3)
42_builder = new BlobBuilder(Math.Max(size, DefaultSize)); 49internal int GetMaxStack() => Math.Min(ushort.MaxValue, _maxStackDepth + _depthAdjustment); 277_maxStackDepth = Math.Max(_maxStackDepth, _currentStackDepth);
System.Reflection.Metadata (25)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Reflection\Internal\Utilities\ImmutableMemoryStream.cs (2)
69int result = Math.Min(count, _array.Length - _position); 80int result = Math.Min(buffer.Length, _array.Length - _position);
System\Reflection\Internal\Utilities\MemoryBlock.cs (1)
67displayedBytes = Math.Min(Length, 64);
System\Reflection\Internal\Utilities\ReadOnlyUnmanagedMemoryStream.cs (2)
33int bytesRead = Math.Min(count, _length - _position); 44int bytesRead = Math.Min(buffer.Length, _length - _position);
System\Reflection\Internal\Utilities\StreamExtensions.cs (2)
24byte[] buffer = new byte[Math.Min(StreamCopyBufferSize, size)]; 27int readSize = Math.Min(size, buffer.Length);
System\Reflection\Metadata\BlobBuilder.cs (8)
63_buffer = new byte[Math.Max(MinChunkSize, capacity)]; 68return new BlobBuilder(Math.Max(_buffer.Length, minimalSize)); 236int minLength = Math.Min(left.Length - leftStart, right.Length - rightStart); 287int bytesToCopy = Math.Min(bufferEnd, chunkEnd) - bufferStart; 534var newChunk = AllocateChunk(Math.Max(newLength, MinChunkSize)); 634int bytesToCurrent = Math.Min(FreeBytes, byteCount); 674int bytesToCurrent = Math.Min(FreeBytes, buffer.Length); 712int bytesToCurrent = Math.Min(FreeBytes, byteCount);
System\Reflection\Metadata\Ecma335\Encoding\ControlFlowBuilder.cs (2)
30internal int OperandSize => Math.Min(_instructionEndDisplacement, 4); 303int chunkSize = Math.Min(branch.OperandOffset - srcOffset, srcBlob.Length - srcBlobOffset);
System\Reflection\Metadata\Ecma335\MetadataBuilder.Heaps.cs (3)
24return new HeapBlobBuilder(Math.Max(Math.Max(minimalSize, ChunkCapacity), _capacityExpansion)); 29_capacityExpansion = Math.Max(0, capacity - Count - FreeBytes);
System\Reflection\PortableExecutable\PEBuilder.cs (2)
446length = Math.Min(remainingHeaderToSign, blobLength); 452length = Math.Min(remainingHeader, blobLength);
System\Reflection\PortableExecutable\PEReader.cs (1)
416int size = Math.Min(
System.Reflection.MetadataLoadContext (1)
System\Reflection\TypeLoading\General\HashHelpers.cs (1)
36int limit = (int)Math.Sqrt(candidate);
System.Runtime (1)
artifacts\obj\System.Runtime\Debug\net10.0\System.Runtime.Forwards.cs (1)
345[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Math))]
System.Runtime.Caching (18)
System\Runtime\Caching\CacheExpires.cs (3)
142return Math.Max(0, (int)((utcExpires - _utcLastCountReset).Ticks / s_COUNT_INTERVAL.Ticks)); 390newLength = Math.Max(oldLength + MIN_PAGES_INCREMENT, newLength); 391newLength = Math.Min(newLength, oldLength + MAX_PAGES_INCREMENT);
System\Runtime\Caching\CacheMemoryMonitor.cs (2)
119memoryLimit = Math.Min(usableMemory, recommendedPrivateByteLimit); 215percent = Math.Min(100, (int)((cacheSize - _memoryLimit) * 100L / cacheSize));
System\Runtime\Caching\CacheUsage.cs (4)
28Debug.Assert((Math.Abs(entryIndex) & ENTRY_MASK) == (Math.Abs(entryIndex)), "(Math.Abs(entryIndex) & ENTRY_MASK) == Math.Abs(entryIndex)"); 375newLength = Math.Max(oldLength + MIN_PAGES_INCREMENT, newLength); 376newLength = Math.Min(newLength, oldLength + MAX_PAGES_INCREMENT);
System\Runtime\Caching\MemoryCacheStatistics.cs (3)
82int newPollingInterval = Math.Min(_configPollingInterval, MEMORYSTATUS_INTERVAL_30_SECONDS); 117return Math.Max(_physicalMemoryMonitor.GetPercentToTrim(_lastTrimTime, _lastTrimPercent), _cacheMemoryMonitor.GetPercentToTrim(_lastTrimTime, _lastTrimPercent)); 286int percent = Math.Max(minPercent, GetPercentToTrim());
System\Runtime\Caching\MemoryCacheStore.cs (1)
383toTrim = (int)Math.Ceiling(((long)count * (long)percent) / 100D);
System\Runtime\Caching\PhysicalMemoryMonitor.cs (4)
89percent = Math.Min(50, (int)((lastTrimPercent * TargetTotalMemoryTrimIntervalTicks) / ticksSinceTrim)); 90percent = Math.Max(MinTotalMemoryTrimPercent, percent); 108_pressureHigh = Math.Max(3, physicalMemoryLimitPercentage); 109_pressureLow = Math.Max(1, _pressureHigh - 9);
System\Runtime\Caching\PhysicalMemoryMonitor.Unix.cs (1)
45return Math.Max(1, memoryLoad);
System.Runtime.Extensions (1)
System.Runtime.Extensions.cs (1)
21[assembly:System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Math))]
System.Runtime.Numerics (90)
src\libraries\Common\src\System\Number.Formatting.Common.cs (2)
134(value, uint remainder) = Math.DivRem(value, 10); 843int zeroes = Math.Min(-digPos, nMaxDigits);
src\libraries\Common\src\System\Number.Parsing.Common.cs (1)
227numberOfTrailingZeros = Math.Min(numberOfTrailingZeros, numberOfFractionalDigits);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
183int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 193nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
System\Number.BigInteger.cs (9)
326ReadOnlySpan<byte> intDigits = number.Digits.Slice(0, Math.Min(number.Scale, number.DigitsCount)); 381int totalDigitCount = Math.Min(number.DigitsCount, number.Scale); 406int powersOf1e9BufferLength = PowersOf1e9.GetBufferSize(Math.Max(valueDigits, trailingZeroCount + 1), out int maxIndex); 501int trailingPartialCount = Math.DivRem(trailingZeroCount, PowersOf1e9.MaxPartialDigits, out int remainingTrailingZeroCount); 665int charsIncludeDigits = Math.Max(digits, charsForBits); 809(ulong quo, ulong rem) = Math.DivRem(uuRes, TenPowMaxPartial); 815(uCarry, base1E9Buffer[cuDst++]) = Math.DivRem(uCarry, TenPowMaxPartial); 829int strDigits = Math.Max(digits, valueDigits); 1129int trailingPartialCount = Math.DivRem(trailingZeroCount, MaxPartialDigits, out int remainingTrailingZeroCount);
System\Numerics\BigInteger.cs (20)
364int wholeUInt32Count = Math.DivRem(byteCount, 4, out int unalignedBytes); 757(quotient, remainder) = Math.DivRem(dividend._sign, divisor._sign); 839return Log(value, Math.E); 851return Math.Log(value._sign, baseValue); 866return Math.Log(x, baseValue) + (b - 64) / Math.Log(baseValue, 2); 1611double significand = (double)highBits * Math.Pow(10, exponentLow - exponent); 1614double log10 = Math.Log10(significand); 1618significand /= Math.Pow(10, Math.Floor(log10)); 1623significand = Math.Round(significand, 8); 2361size = Math.Max(x.Length, y.Length); 2417size = Math.Max(x.Length, y.Length); 2468size = Math.Max(x.Length, y.Length); 2505(int digitShift, int smallShift) = Math.DivRem(shift, kcbitUint); 2564(int digitShift, int smallShift) = Math.DivRem(shift, kcbitUint); 2597int zl = Math.Max(xl - digitShift, 0) + (trackSignBit ? 1 : 0); 3256(int digitShift, int smallShift) = Math.DivRem(rotateAmount, kcbitUint); 3391(int digitShift, int smallShift) = Math.DivRem(rotateAmount, kcbitUint); 5238(int digitShift, int smallShift) = Math.DivRem(shiftAmount, kcbitUint);
System\Numerics\BigIntegerCalculator.PowMod.cs (2)
218int size = Math.Max(value.Length, bits.Length); 266int size = Math.Max(value.Length, bits.Length);
System\Numerics\Complex.cs (51)
42private static readonly double s_sqrtRescaleThreshold = double.MaxValue / (Math.Sqrt(2.0) + 1.0); 45private static readonly double s_asinOverflowThreshold = Math.Sqrt(double.MaxValue) / 2.0; 48private static readonly double s_log2 = Math.Log(2.0); 64public double Phase { get { return Math.Atan2(m_imaginary, m_real); } } 68(double sin, double cos) = Math.SinCos(phase); 229if (Math.Abs(d) < Math.Abs(c)) 278if (Math.Abs(d) < Math.Abs(c)) 312return x * Math.Log(xp1) / (xp1 - 1.0); 316return Math.Log(xp1); 379(double sin, double cos) = Math.SinCos(value.m_real); 380return new Complex(sin * Math.Cosh(value.m_imaginary), cos * Math.Sinh(value.m_imaginary)); 397Asin_Internal(Math.Abs(value.Real), Math.Abs(value.Imaginary), out b, out bPrime, out v); 402u = Math.Asin(b); 406u = Math.Atan(bPrime); 417(double sin, double cos) = Math.SinCos(value.m_real); 418return new Complex(cos * Math.Cosh(value.m_imaginary), -sin * Math.Sinh(value.m_imaginary)); 430Asin_Internal(Math.Abs(value.Real), Math.Abs(value.Imaginary), out b, out bPrime, out v); 435u = Math.Acos(b); 439u = Math.Atan(1.0 / bPrime); 442if (value.Real < 0.0) u = Math.PI - u; 461(double sin, double cos) = Math.SinCos(x2); 462double cosh = Math.Cosh(y2); 463if (Math.Abs(value.m_imaginary) <= 4.0) 466return new Complex(sin / D, Math.Sinh(y2) / D); 471return new Complex(sin / cosh / D, Math.Tanh(y2) / D); 550v = s_log2 + Math.Log(big) + 0.5 * Log1P(ratio * ratio); 565bPrime = x / Math.Sqrt((a + x) * amx); 573bPrime = x / y / Math.Sqrt((a + x) * t); 590v = Log1P(am1 + y * Math.Sqrt(t * (a + 1.0))); 595v = Log1P(am1 + Math.Sqrt(am1 * (a + 1.0))); 601v = Math.Log(a + Math.Sqrt((a - 1.0) * (a + 1.0))); 614return new Complex(Math.Log(Abs(value)), Math.Atan2(value.m_imaginary, value.m_real)); 630double expReal = Math.Exp(value.m_real); 664return new Complex(0.0, Math.Sqrt(-value.m_real)); 667return new Complex(Math.Sqrt(value.m_real), 0.0); 699if ((Math.Abs(realCopy) >= s_sqrtRescaleThreshold) || (Math.Abs(imaginaryCopy) >= s_sqrtRescaleThreshold)) 717x = Math.Sqrt((double.Hypot(realCopy, imaginaryCopy) + realCopy) * 0.5); 722y = Math.Sqrt((double.Hypot(realCopy, imaginaryCopy) - realCopy) * 0.5); 754double theta = Math.Atan2(valueImaginary, valueReal); 755double newRho = powerReal * theta + powerImaginary * Math.Log(rho); 757double t = Math.Pow(rho, powerReal) * Math.Exp(-powerImaginary * theta);
System.Runtime.Serialization.Formatters (2)
src\libraries\System.Private.CoreLib\src\System\Collections\HashHelpers.cs (1)
44int limit = (int)Math.Sqrt(candidate);
System\Runtime\Serialization\FormatterServices.cs (1)
157Array.Resize(ref parentTypes, Math.Max(parentTypeCount * 2, 12));
System.Runtime.Serialization.Schema (1)
System\Runtime\Serialization\Schema\CodeExporter.cs (1)
1545length = Math.Min(MaxIdentifierLength, length);
System.Security.Cryptography (24)
src\libraries\Common\src\System\IO\MemoryMappedFiles\MemoryMappedFileMemoryManager.cs (1)
42int length = (int)Math.Min(int.MaxValue, fileStream.Length);
src\libraries\Common\src\System\Security\Cryptography\ECDiffieHellmanDerivation.cs (1)
220int len = Math.Min(p.Length, retSpan.Length);
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (1)
288Span<byte> nullTerminator = destination.Slice(0, Math.Min(2, destination.Length));
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Security\Cryptography\Base64Transforms.cs (2)
33int inputBlocks = Math.DivRem(inputCount, InputBlockSize, out int inputRemainder); 71int inputBlocks = Math.DivRem(inputCount, InputBlockSize, out int inputRemainder);
System\Security\Cryptography\CryptoStream.cs (1)
315int bytesToCopy = Math.Min(_outputBufferIndex, buffer.Length);
System\Security\Cryptography\LiteHashProvider.cs (2)
125maxRead = Math.Max(maxRead, read); 156maxRead = Math.Max(maxRead, read);
System\Security\Cryptography\LiteHashProvider.Xof.cs (1)
141maxRead = Math.Max(maxRead, read);
System\Security\Cryptography\PemEncoding.cs (1)
401int lineCount = Math.DivRem(encodedDataLength, EncodedLineLength, out int remainder);
System\Security\Cryptography\PKCS1MaskGenerationMethod.cs (1)
49Buffer.BlockCopy(hash, 0, rgbT, ib, Math.Min(rgbT.Length - ib, hash.Length));
System\Security\Cryptography\RandomNumberGenerator.cs (2)
317Span<byte> remainingRandom = randomBuffer.Slice(0, Math.Min(RandomBufferSize, needed)); 337remainingRandom = randomBuffer.Slice(0, Math.Min(RandomBufferSize, needed));
System\Security\Cryptography\SymmetricAlgorithm.cs (2)
323int wholeBlocks = Math.DivRem(plaintextLength, blockSizeBytes, out int remainder) * blockSizeBytes; 402int feedbackAligned = Math.DivRem(plaintextLength, feedbackSizeInBytes, out int remainder) * feedbackSizeInBytes;
System\Security\Cryptography\SymmetricPadding.cs (1)
16int wholeBlocks = Math.DivRem(plaintextLength, paddingSizeInBytes, out int remainder) * paddingSizeInBytes;
System\Security\Cryptography\X509Certificates\CertificatePolicy.cs (1)
222restriction = Math.Min(restriction, policyRestriction.Value);
System\Security\Cryptography\X509Certificates\OpenSslX509ChainProcessor.cs (3)
1380int size = Math.Max(DefaultChainCapacity, errorDepth + 1); 1398LastError = Math.Max(errorDepth, LastError); 1565bucket = Math.DivRem(val, 32, out int localBitNumber);
System\Security\Cryptography\XmlKeyHelper.cs (2)
81int idx = Math.Max(0, buf.Length - sizeof(int)); 144int localLength = Math.Min(ByteLimit, length);
System.Security.Cryptography.Cose (2)
System\Security\Cryptography\Cose\CoseMultiSignMessage.cs (2)
793byte[] buffer = ArrayPool<byte>.Shared.Rent(Math.Max(toBeSignedLength, CoseHelpers.ComputeSignatureSize(signer))); 869byte[] buffer = ArrayPool<byte>.Shared.Rent(Math.Max(toBeSignedLength, CoseHelpers.ComputeSignatureSize(signer)));
System.Security.Cryptography.Pkcs (4)
src\libraries\Common\src\System\Security\Cryptography\Pkcs12Kdf.cs (1)
288Span<byte> nullTerminator = destination.Slice(0, Math.Min(2, destination.Length));
System\Security\Cryptography\Pkcs\Asn1\Rfc3161Accuracy.manual.cs (2)
19long totalMillis = Math.DivRem(accuracyInMicroseconds, 1000, out long micros); 20long seconds = Math.DivRem(totalMillis, 1000, out long millis);
System\Security\Cryptography\Pkcs\Pkcs12Builder.cs (1)
207salt = stackalloc byte[Math.Min(macKey.Length, 128)];
System.ServiceModel.Federation (1)
System\ServiceModel\Federation\WSTrustChannelSecurityTokenProvider.cs (1)
356DateTime effectiveExpiration = AddTicks(fromTime, Math.Min(effectiveInterval, WSTrustTokenParameters.MaxIssuedTokenCachingTime.Ticks));
System.ServiceModel.NetFramingBase (11)
System\ServiceModel\Channels\Connection.cs (1)
72int bytesToCopy = Math.Min(buffer.Length, _preReadData.Length);
System\ServiceModel\Channels\FramingChannels.cs (2)
382Math.Min(FaultStringDecoder.FaultSizeQuota, connection.ConnectionBufferSize)), 408Math.Min(FaultStringDecoder.FaultSizeQuota, connection.ConnectionBufferSize)),
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\Runtime\BackoffTimeoutHelper.cs (1)
72return Ticks.ToTimeSpan(Math.Max(
System.ServiceModel.Syndication (1)
System\ServiceModel\XmlBuffer.cs (1)
48int initialBufferSize = Math.Min(512, maxBufferSize);
System.Text.Encodings.Web (6)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System\Text\Encodings\Web\TextEncoder.cs (4)
161int minBufferBumpEachIteration = Math.Max(MaxOutputCharactersPerInputCharacter, EncodeStartingOutputBufferSize); 166Span<char> destBuffer = stringBuilder.AppendSpan(Math.Max(remainingInput.Length, minBufferBumpEachIteration)); 520int minBufferBumpEachIteration = Math.Max(MaxOutputCharactersPerInputCharacter, EncodeStartingOutputBufferSize); 521char[] rentedArray = ArrayPool<char>.Shared.Rent(Math.Max(value.Length, minBufferBumpEachIteration));
System.Text.Json (22)
src\libraries\Common\src\System\Text\Json\PooledByteBufferWriter.cs (2)
182sizeHint = Math.Max(sizeHint, MaximumBufferSize - currentLength); 187int growBy = Math.Max(sizeHint, currentLength);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Text.Json\Common\JsonHelpers.cs (1)
117var adjacencyRow = new bool[Math.Max(nodes.Count, count)];
System\Text\Json\BitStack.cs (1)
138int nextDouble = Math.Max(minSize + 1, _array.Length * 2);
System\Text\Json\Document\JsonDocument.Parse.cs (2)
774long expectedLength = Math.Max(utf8Bom.Length, stream.Length - stream.Position) + 1; 857long expectedLength = Math.Max(utf8BomLength, stream.Length - stream.Position) + 1;
System\Text\Json\JsonHelpers.Date.cs (1)
308int fractionEnd = Math.Min(sourceIndex + JsonConstants.DateTimeParseNumFractionDigits, source.Length);
System\Text\Json\Reader\Utf8JsonReader.MultiSegment.cs (4)
551int amountToWrite = Math.Min(span.Length, (int)_bytePositionInLine + 1); 561int amountToWrite = Math.Min(span.Length, (int)_bytePositionInLine + 1); 588int amountToWrite = Math.Min(span.Length, readSoFar.Length - written); 608amountToWrite = Math.Min(span.Length, (int)_bytePositionInLine + 1);
System\Text\Json\Serialization\Converters\Object\ObjectWithParameterizedConstructorConverter.cs (2)
350ArrayPool<FoundProperty>.Shared.Rent(Math.Max(1, state.Current.JsonTypeInfo.PropertyCache.Length)); 546argumentState.FoundPropertiesAsync = ArrayPool<FoundPropertyAsync>.Shared.Rent(Math.Max(1, state.Current.JsonTypeInfo.PropertyCache.Length));
System\Text\Json\Serialization\Metadata\JsonTypeInfo.Cache.cs (1)
98int iForward = Math.Min(propertyIndex, count);
System\Text\Json\Serialization\ReadBufferState.cs (1)
46_buffer = ArrayPool<byte>.Shared.Rent(Math.Max(initialBufferSize, JsonConstants.Utf8Bom.Length));
System\Text\Json\Serialization\WriteStack.cs (2)
317int stackSize = Math.Max(_count, _continuationCount); 355int stackSize = Math.Max(_count, _continuationCount);
System\Text\Json\ThrowHelper.cs (1)
519int printFirst10 = Math.Min(value.Length, 10);
System\Text\Json\Writer\Utf8JsonWriter.cs (2)
1196int sizeHint = Math.Max(DefaultGrowthSize, requiredSize); 1233int sizeHint = Math.Max(InitialGrowthSize, requiredSize);
System.Text.Json.SourceGeneration (1)
src\libraries\System.Text.Json\Common\JsonHelpers.cs (1)
117var adjacencyRow = new bool[Math.Max(nodes.Count, count)];
System.Text.RegularExpressions (39)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
183int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 193nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
System\Text\RegularExpressions\Regex.EnumerateSplits.cs (1)
233int start = _lastMatch.Index + Math.Max(_lastMatch.Length, 0);
System\Text\RegularExpressions\RegexCompiler.cs (3)
103private static MethodInfo MathMinIntIntMethod => field ??= typeof(Math).GetMethod("Min", [typeof(int), typeof(int)])!; 849int setsToUse = Math.Min(sets.Count, MaxSets); 1093maxDistance = Math.Max(maxDistance, sets[i].Distance);
System\Text\RegularExpressions\RegexFindOptimizations.cs (1)
715int endMinusRequiredLength = textSpan.Length - Math.Max(1, MinRequiredLength);
System\Text\RegularExpressions\RegexInterpreterCode.cs (1)
234string Indent() => new string(' ', Math.Max(1, 25 - sb.Length));
System\Text\RegularExpressions\RegexNode.cs (8)
1279int minLength = Math.Min(startingSpan.Length, startingNode.Str.Length); 2287return (int)Math.Min(int.MaxValue - 1, (long)M * Child(0).ComputeMinLength()); 2297min = Math.Min(min, Child(i).ComputeMinLength()); 2304return Math.Min(Child(0).ComputeMinLength(), Child(1).ComputeMinLength()); 2308return Math.Min(Child(1).ComputeMinLength(), Child(2).ComputeMinLength()); 2319return (int)Math.Min(int.MaxValue - 1, sum); 2423maxLength = Math.Max(maxLength, next); 2435Math.Max(yes, no) :
System\Text\RegularExpressions\RegexParser.cs (1)
1436int c = Math.Min(3, _pattern.Length - _pos);
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\Symbolic\BDD.cs (1)
316m = Math.Max(serialized[i], m);
System\Text\RegularExpressions\Symbolic\BitVector.cs (2)
74(int block, int bit) = Math.DivRem(i, 64); 82(int block, int bit) = Math.DivRem(i, 64);
System\Text\RegularExpressions\Symbolic\MintermClassifier.cs (1)
61maxChar = Math.Max(maxChar, (int)ranges[^1].Item2);
System\Text\RegularExpressions\Symbolic\RegexNodeConverter.cs (2)
400BDD cond = MapCategoryCodeToCondition((UnicodeCategory)(Math.Abs(categoryCode) - 1)); 427int cat = Math.Abs((int)categoryCode) - 1;
System\Text\RegularExpressions\Symbolic\SparseIntMap.cs (1)
79newLength = Math.Max(2 * _sparse.Length, newLength);
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.Automata.cs (1)
321int newsize = Math.Max(_nfaCoreIdArray.Length * 2, InitialNfaStateCapacity);
System\Text\RegularExpressions\Symbolic\SymbolicRegexNode.cs (2)
2333return (int)Math.Min((long)m + n, int.MaxValue); 2340return (int)Math.Min((long)m * n, int.MaxValue);
System.Text.RegularExpressions.Generator (26)
RegexGenerator.Emitter.cs (2)
1143int setsToUse = Math.Min(sets.Count, MaxSets); 1253maxDistance = Math.Max(maxDistance, sets[i].Distance);
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
src\libraries\System.Private.CoreLib\src\System\Collections\Generic\ValueListBuilder.cs (3)
183int nextCapacity = Math.Max(_span.Length != 0 ? _span.Length * 2 : 4, _span.Length + additionalCapacityRequired); 193nextCapacity = Math.Max(Math.Max(_span.Length + 1, ArrayMaxLength), _span.Length);
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexNode.cs (8)
1279int minLength = Math.Min(startingSpan.Length, startingNode.Str.Length); 2287return (int)Math.Min(int.MaxValue - 1, (long)M * Child(0).ComputeMinLength()); 2297min = Math.Min(min, Child(i).ComputeMinLength()); 2304return Math.Min(Child(0).ComputeMinLength(), Child(1).ComputeMinLength()); 2308return Math.Min(Child(1).ComputeMinLength(), Child(2).ComputeMinLength()); 2319return (int)Math.Min(int.MaxValue - 1, sum); 2423maxLength = Math.Max(maxLength, next); 2435Math.Max(yes, no) :
src\libraries\System.Text.RegularExpressions\src\System\Text\RegularExpressions\RegexParser.cs (1)
1436int c = Math.Min(3, _pattern.Length - _pos);
src\libraries\System.Text.RegularExpressions\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));
Stubs.cs (1)
47int length = Math.Min(span.Length, other.Length);
System.Threading (2)
System\Threading\Barrier.cs (2)
874int waitTime = totalTimeout == Timeout.Infinite ? maxWait : Math.Min(maxWait, totalTimeout); 888maxWait = maxWait >= waitTimeCeiling ? waitTimeCeiling : Math.Min(maxWait << 1, waitTimeCeiling);
System.Threading.Channels (1)
src\libraries\Common\src\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs (1)
111int newSegmentSize = Math.Min(_tail._array.Length * 2, MaxSegmentSize);
System.Threading.RateLimiting (3)
System\Threading\RateLimiting\FixedWindowRateLimiter.cs (1)
216int replenishWindow = Math.Max(replenishAmount / _options.PermitLimit, 1);
System\Threading\RateLimiting\TokenBucketRateLimiter.cs (2)
223int replenishPeriods = Math.Max(replenishAmount / _options.TokensPerPeriod, 1); 317_tokenCount = Math.Min(_options.TokenLimit, _tokenCount + add);
System.Threading.Tasks.Dataflow (1)
src\libraries\Common\src\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs (1)
111int newSegmentSize = Math.Min(_tail._array.Length * 2, MaxSegmentSize);
System.Threading.Tasks.Parallel (1)
System\Threading\Tasks\Parallel.cs (1)
116rval = (rval == -1) ? schedulerMax : Math.Min(schedulerMax, rval);
System.Web.HttpUtility (2)
src\libraries\Common\src\System\Text\ValueStringBuilder.cs (2)
304int newCapacity = (int)Math.Max( 306Math.Min((uint)_chars.Length * 2, ArrayMaxLength));
System.Windows.Controls.Ribbon (105)
Microsoft\Windows\Controls\KeyTipAdorner.cs (2)
313if (DoubleUtil.LessThan(Math.Abs(keyTipTopY), RibbonGroupKeyTipAxisNudgeSpace)) 318else if (DoubleUtil.LessThan(Math.Abs(itemsPresenter.ActualHeight - keyTipBottomY), RibbonGroupKeyTipAxisNudgeSpace))
Microsoft\Windows\Controls\Ribbon\NativeMethods.cs (1)
592handleCount = Math.Max(0, handleCount);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonContextualTabGroupsPanel.cs (5)
72if (Math.Abs(tabGroupHeader.TabsDesiredWidth - remainingSpace) > _desiredWidthEpsilon) 75width = Math.Min(tabGroupHeader.TabsDesiredWidth, remainingSpace); 88desiredSize.Height = Math.Max(desiredSize.Height, tabGroupHeader.DesiredSize.Height); 108double width = Math.Max(tabGroupHeader.ArrangeWidth,0); 113tabGroupHeader.Arrange(new Rect(startX, y, width, Math.Max(0.0, height - 1)));
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGalleryCategoriesPanel.cs (10)
387maxChildWidth = Math.Max(maxChildWidth, childSize.Width); 388maxChildHeight = Math.Max(maxChildHeight, childSize.Height); 462stackDesiredSize.Width = Math.Max(stackDesiredSize.Width, childDesiredSize.Width); 472stackDesiredSize.Width = Math.Min(stackDesiredSize.Width, constraint.Width); 473stackDesiredSize.Height = Math.Min(stackDesiredSize.Height, constraint.Height); 492logicalVisibleSpace = DoubleUtil.LessThanOrClose((viewportOffsetY + logicalVisibleSpace) - stackDesiredSize.Height, 0.0) ? 0.0 : Math.Min((viewportOffsetY + logicalVisibleSpace) - stackDesiredSize.Height, constraint.Height); 493viewportOffsetY = Math.Max(viewportOffsetY - logicalVisibleSpace, 0.0); 496offset.X = Math.Max(0, Math.Min(offset.X, extent.Width - viewport.Width)); 602rcChild.Width = Math.Max(finalSize.Width, child.DesiredSize.Width);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGalleryItemsPanel.cs (25)
341maxColumnWidth = Math.Max(maxColumnWidth, childSize.Width); 342maxItemHeight = Math.Max(maxItemHeight, childSize.Height); 363columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / maxColumnWidth), childrenCount)), maxColumnCount); 375columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / maxColumnWidth), childrenCount)), maxColumnCount); 376arrangeWidth = Math.Max(availableSize.Width / columnCount, maxColumnWidth); 382columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / arrangeWidth), childrenCount)), maxColumnCount); 391columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / maxColumnWidth), childrenCount)), maxColumnCount); 392_arrangeWidth = Math.Max(availableSize.Width / columnCount, maxColumnWidth); 398columnCount = Math.Min(Math.Max(minColumnCount, Math.Min((int)(availableSize.Width / _arrangeWidth), childrenCount)), maxColumnCount); 405columnCount = Math.Max(minColumnCount, Math.Min(childrenCount, maxColumnCount)); 414maxRowHeight = Math.Max(maxRowHeight, childSize.Height); 567finalColumnCount = Math.Max(minColumnCount, Math.Min((int)(finalSize.Width / arrangeWidth), maxColumnCount)); 576maxRowHeight = Math.Max(maxRowHeight, children[i].DesiredSize.Height);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGroupItemsPanel.cs (14)
83remainingHeightInColumn = Math.Max(0, finalSize.Height - childDesiredSize.Height); 105columnWidth = Math.Max(columnWidth, arrangeWidth); 136maxStarColumnWidth = Math.Max(maxStarColumnWidth, child.MaxWidth); 141maxStarColumnWidth = Math.Max(maxStarColumnWidth, Math.Min(child.MaxWidth, child.DesiredSize.Width)); 223desiredHeight = Math.Min(Math.Max(desiredHeight, columnHeight), availableSize.Height); 248columnWidth = Math.Max(columnWidth, GetStarChildMinWidth(child as FrameworkElement, ref maxStarColumnWidth)); 252columnWidth = Math.Max(columnWidth, childDesiredSize.Width); 253maxStarColumnWidth = Math.Max(maxStarColumnWidth, columnWidth); 258desiredHeight = Math.Min(Math.Max(desiredHeight, columnHeight), availableSize.Height); 358columnDesiredWidth = Math.Max(columnDesiredWidth, child.DesiredSize.Width); 375desiredWidth += Math.Max((columnDesiredWidth - starLayoutInfo.RequestedStarMinWidth), 0);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonGroupsPanel.cs (2)
156remainingSpace = Math.Max(0, remainingSpace - 1); 482double targetValue = Math.Min(basePerStar * starInfo.RequestedStarWeight, starInfo.RequestedStarMaxWidth);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonMenuItemsPanel.cs (3)
138maxChildWidth = Math.Max(availableSize.Width, maxChildWidth); 155double surplusHeight = Math.Max(remainingHeight, 0.0) / _registeredStarLayoutProviders.Count; 172desiredSize.Width = Math.Max(starLayoutTarget.DesiredSize.Width, desiredSize.Width);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonQuickAccessToolBarOverflowPanel.cs (2)
31panelDesiredSize.Height = Math.Max(panelDesiredSize.Height, child.DesiredSize.Height); 50rcChild.Height = Math.Max(finalSize.Height, child.DesiredSize.Height);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonQuickAccessToolBarPanel.cs (2)
217panelDesiredSize.Height = Math.Max(panelDesiredSize.Height, childDesiredSize.Height); 285rcChild.Height = Math.Max(finalSize.Height, child.DesiredSize.Height);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonScrollButtonVisibilityConverter.cs (2)
90double percent = Math.Min(100.0, Math.Max(0.0, (offset * 100.0 / (extent - viewport))));
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonTabHeadersPanel.cs (11)
90_separatorOpacity = Math.Max(0.0, reducePaddingRegularTabHeader * 0.2); 123double availableExtraWidth = Math.Min(desiredExtraPaddingPerTab, availableExtraWidthPerTab); 143if (Math.Abs(desiredSize.Width - availableSize.Width) < _desiredWidthEpsilon) 396desiredSize.Height = Math.Max(desiredSize.Height, ribbonTabHeader.DesiredSize.Height); 413desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height); 444double leftPadding = Math.Max(0, ribbonTabHeader.DefaultPadding.Left - (isContextualTab ? reducePaddingContextualTabHeader : reducePaddingRegularTabHeader)); 445double rightPadding = Math.Max(0, ribbonTabHeader.DefaultPadding.Right - (isContextualTab ? reducePaddingContextualTabHeader : reducePaddingRegularTabHeader)); 451desiredSize.Height = Math.Max(desiredSize.Height, ribbonTabHeader.DesiredSize.Height); 462desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height); 527return Math.Max(_tabHeaderMinWidth, maxTabHeaderWidth); 1064return Math.Max(0.0, offset);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonTabsPanel.cs (3)
42returnSize = new Size(Math.Max(returnSize.Width, childSize.Width), Math.Max(returnSize.Height, childSize.Height)); 301return Math.Max(0.0, offset);
Microsoft\Windows\Controls\Ribbon\Primitives\RibbonTitlePanel.cs (14)
77startContextualTabX = Math.Min(CalculateContextualTabGroupStartX(firstContextualTab), availableSize.Width); 83endContextualTabX = Math.Min(CalculateContextualTabGroupEndX(lastContextualTab), availableSize.Width); 86groupHeaderItemsControl.Measure(new Size(Math.Max(endContextualTabX - startContextualTabX, 0), availableSize.Height)); 88desiredSize.Height = Math.Max(desiredSize.Height, groupHeaderItemsControl.DesiredSize.Height); 123availableToQat = Math.Max(availableToQat, 0); 130desiredSize.Height = Math.Max(desiredSize.Height, qat.DesiredSize.Height); 135endContextualTabX = Math.Max(endContextualTabX, availableToQat); 148availableToTitle = Math.Max(leftSpace, rightSpace); 154availableToTitle = Math.Max(availableToTitle, 0); 158desiredSize.Height = Math.Max(desiredSize.Height, titleHost.DesiredSize.Height); 161desiredSize.Width = Math.Min(desiredSize.Width, availableSize.Width); // Prevent clipping 186startContextualTabX = Math.Min(CalculateContextualTabGroupStartX(firstContextualTab), finalSize.Width); 189endContextualTabX = Math.Min(startContextualTabX + tabGroups.DesiredSize.Width, finalSize.Width); 202endContextualTabX = Math.Max(endContextualTabX, qatDesiredWidth);
Microsoft\Windows\Controls\Ribbon\Ribbon.cs (2)
976if (DoubleUtil.GreaterThan(Math.Abs(_mouseWheelCumulativeDelta), MouseWheelSelectionChangeThreshold)) 1619double screenWidth = Math.Abs(popupPlacementTarget.PointFromScreen(screenRect.BottomRight).X -
Microsoft\Windows\Controls\Ribbon\RibbonTwoLineText.cs (3)
395_textBlock1.Width = Math.Max(1.0, width / 2.0); 412extraLength += Math.Abs(lastCharacter.X - firstCharacter.X); 420extraLength += Math.Abs(lastCharacter.X - firstCharacter.X);
MS\Internal\Generated\DoubleUtil.cs (4)
41double eps = (Math.Abs(value1) + Math.Abs(value2) + 10.0) * DBL_EPSILON; 140return Math.Abs(value - 1.0) < 10.0 * DBL_EPSILON; 153return Math.Abs(value) < 10.0 * DBL_EPSILON;
System.Windows.Forms (604)
System\Windows\Forms\Accessibility\LabelEditUiaTextProvider.cs (5)
288clientLocation.X = Math.Max(clientLocation.X, clientRectangle.left); 289clientLocation.X = Math.Min(clientLocation.X, clientRectangle.right); 290clientLocation.Y = Math.Max(clientLocation.Y, clientRectangle.top); 291clientLocation.Y = Math.Min(clientLocation.Y, clientRectangle.bottom); 344index = Math.Max(t.Length - 1, 0);
System\Windows\Forms\Application.cs (2)
384systemColorMode = Math.Abs((Registry.GetValue( 1017i = Math.Min(i, s_forms.Count); // Form can be removed from the collection, we need to check it
System\Windows\Forms\Control.cs (20)
4916int width = Math.Min(Width, targetBounds.Width); 4917int height = Math.Min(Height, targetBounds.Height); 5295sx = (int)Math.Round(bounds.X * dx); 5300sy = (int)Math.Round(bounds.Y * dy); 5330sw = (int)Math.Round(localWidth * dx) + adornmentsAfterDpiChange.Width; 5336sh = (int)Math.Round(localHeight * dy) + adornmentsAfterDpiChange.Height; 9727padding.Left = (int)Math.Round(padding.Left * dx); 9728padding.Right = (int)Math.Round(padding.Right * dx); 9729margins.Left = (int)Math.Round(margins.Left * dx); 9730margins.Right = (int)Math.Round(margins.Right * dx); 9735padding.Top = (int)Math.Round(padding.Top * dy); 9736padding.Bottom = (int)Math.Round(padding.Bottom * dy); 9737margins.Top = (int)Math.Round(margins.Top * dy); 9738margins.Bottom = (int)Math.Round(margins.Bottom * dy); 9800int sx = (int)Math.Round(_x * dx); 9801int sy = (int)Math.Round(_y * dy); 9806sw = (int)(Math.Round((_x + _width) * dx)) - sx; 9812sh = (int)(Math.Round((_y + _height) * dy)) - sy; 9836size.Width = (int)Math.Round(size.Width * x); 9841size.Height = (int)Math.Round(size.Height * y);
System\Windows\Forms\Controls\Buttons\ButtonInternal\ButtonBaseAdapter.cs (2)
330size = Math.Min(size, Math.Min(bounds.Width, bounds.Height));
System\Windows\Forms\Controls\Buttons\ButtonInternal\ButtonBaseAdapter.LayoutOptions.cs (18)
132return Math.Max(checkSize, imageSize + textSize); 134return Math.Max(imageSize, textSize) + checkSize; 136return Math.Max(Math.Max(checkSize, imageSize), textSize); 578int textBottom = Math.Min(layout.TextBounds.Bottom, layout.Field.Bottom); 579layout.TextBounds.Y = Math.Max( 580Math.Min(layout.TextBounds.Y, layout.Field.Y + (layout.Field.Height - layout.TextBounds.Height) / 2), 588int textRight = Math.Min(layout.TextBounds.Right, layout.Field.Right); 589layout.TextBounds.X = Math.Max( 590Math.Min(layout.TextBounds.X, layout.Field.X + (layout.Field.Width - layout.TextBounds.Width) / 2), 598layout.ImageBounds.Width = Math.Max( 600Math.Min(maxBounds.Width - layout.TextBounds.Width, layout.ImageBounds.Width)); 607layout.ImageBounds.Height = Math.Max( 609Math.Min(maxBounds.Height - layout.TextBounds.Height, layout.ImageBounds.Height)); 645bottom = Math.Min(layout.TextBounds.Bottom, maxBounds.Bottom); 646layout.TextBounds.Y = Math.Max(layout.TextBounds.Y, maxBounds.Y); 652bottom = Math.Min(layout.TextBounds.Bottom, layout.Field.Bottom); 653layout.TextBounds.Y = Math.Max(layout.TextBounds.Y, layout.Field.Y);
System\Windows\Forms\Controls\Buttons\CheckBox.cs (1)
288size.Height = Math.Max(size.Height + 5, _flatSystemStyleMinimumHeight);
System\Windows\Forms\Controls\Buttons\RadioButton.cs (1)
260? Math.Max(size.Height + 5, _flatSystemStyleMinimumHeight)
System\Windows\Forms\Controls\ComboBox\ComboBox.ComboBoxUiaTextProvider.cs (5)
361clientLocation.X = Math.Max(clientLocation.X, clientRectangle.left); 362clientLocation.X = Math.Min(clientLocation.X, clientRectangle.right); 363clientLocation.Y = Math.Max(clientLocation.Y, clientRectangle.top); 364clientLocation.Y = Math.Min(clientLocation.Y, clientRectangle.bottom); 419index = Math.Max(t.Length - 1, 0);
System\Windows\Forms\Controls\ComboBox\ComboBox.cs (3)
2200return actualLength == PInvoke.LB_ERR ? string.Empty : buffer[..Math.Min(maxLength, actualLength)].ToString(); 3358int count = Math.Min(Math.Max(itemCount, 1), _maxDropDownItems);
System\Windows\Forms\Controls\DataGridView\DataGridView.DataConnection.cs (2)
618int lo = Math.Min(e.OldIndex, e.NewIndex); 619int hi = Math.Max(e.OldIndex, e.NewIndex);
System\Windows\Forms\Controls\DataGridView\DataGridView.Methods.cs (91)
663dataGridViewColumnTmp.UsedFillWeight = Math.Max( 696Debug.Assert(Math.Abs(weightSum - weightSumDbg) < 1.0F); 831dataGridViewColumnTmp.UsedFillWeight = Math.Max(dataGridViewColumnTmp.FillWeight * usedWeightSumNoneMinimal / weightSumNoneMinimal, 863Debug.Assert(Math.Abs(weightSum - weightSumDbg) < 1.0F); 1004dataGridViewColumn.DesiredFillWidth = (int)Math.Round(desiredFillWidth, MidpointRounding.AwayFromZero); 1126int widthLoss = Math.Min(stepDownAvailableWidthForFillColumns - availableWidth, Math.Max(1, (int)(stepDownAvailableWidthForFillColumns * 0.1F))); 1159mostDeservingDataGridViewColumn.DesiredFillWidth = Math.Min(oldDesiredWidth, (int)Math.Round(floatDesiredWidth, MidpointRounding.AwayFromZero)); 1198Debug.Assert(Math.Abs(weightSum - weightSumDbg) < 1.0F); 1213mostDeservingDataGridViewColumn.DesiredFillWidth = Math.Max(availableWidth - usedWidth, mostDeservingDataGridViewColumn.MinimumWidth); 1222weightDiscrepancy = Math.Abs(dataGridViewColumn.UsedFillWeight - dataGridViewColumn.FillWeight) / dataGridViewColumn.FillWeight; 1231mostDeservingDataGridViewColumn.DesiredFillWidth = Math.Max(mostDeservingDataGridViewColumn.MinimumWidth, (int)Math.Round(floatDesiredWidth, MidpointRounding.AwayFromZero)); 1257Debug.Assert(Math.Abs(dataGridViewColumnTmp.UsedFillWeight * _availableWidthForFillColumns - weightSum * dataGridViewColumnTmp.Width) / weightSum / dataGridViewColumnTmp.Width <= 1.25F / dataGridViewColumnTmp.Width); 1771? Math.Max(preferredHeight, Columns[columnIndex].HeaderCell.GetPreferredHeight(-1, Columns[columnIndex].Thickness)) 1772: Math.Max(preferredHeight, Columns[columnIndex].HeaderCell.GetPreferredSize(-1).Height); 1836? Math.Max(preferredHeight, Columns[columnIndexTmp].HeaderCell.GetPreferredHeight(-1, Columns[columnIndexTmp].Thickness)) 1837: Math.Max(preferredHeight, Columns[columnIndexTmp].HeaderCell.GetPreferredSize(-1).Height); 2031? Math.Max(preferredWidth, Rows.SharedRow(rowIndex).HeaderCell.GetPreferredWidth(rowIndex, Rows.SharedRow(rowIndex).GetHeight(rowIndex))) 2032: Math.Max(preferredWidth, Rows.SharedRow(rowIndex).HeaderCell.GetPreferredSize(rowIndex).Width); 2048? Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredWidth(rowIndex, dataGridViewRowHeight)) 2049: Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredSize(rowIndex).Width); 2065? Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredWidth(rowIndex, dataGridViewRowHeight)) 2066: Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredSize(rowIndex).Width); 2082? Math.Max(preferredWidth, Rows.SharedRow(rowIndex).HeaderCell.GetPreferredWidth(rowIndex, Rows.SharedRow(rowIndex).GetHeight(rowIndex))) 2083: Math.Max(preferredWidth, Rows.SharedRow(rowIndex).HeaderCell.GetPreferredSize(rowIndex).Width); 2193? Math.Max(preferredWidth, Rows.SharedRow(rowIndexTmp).HeaderCell.GetPreferredWidth(rowIndexTmp, Rows.SharedRow(rowIndexTmp).GetHeight(rowIndexTmp))) 2194: Math.Max(preferredWidth, Rows.SharedRow(rowIndexTmp).HeaderCell.GetPreferredSize(rowIndexTmp).Width); 2210? Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredWidth(rowIndexTmp, dataGridViewRowHeight)) 2211: Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredSize(rowIndexTmp).Width); 2227? Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredWidth(rowIndexTmp, dataGridViewRowHeight)) 2228: Math.Max(preferredWidth, dataGridViewRow.HeaderCell.GetPreferredSize(rowIndexTmp).Width); 2244? Math.Max(preferredWidth, Rows.SharedRow(rowIndexTmp).HeaderCell.GetPreferredWidth(rowIndexTmp, Rows.SharedRow(rowIndexTmp).GetHeight(rowIndexTmp))) 2245: Math.Max(preferredWidth, Rows.SharedRow(rowIndexTmp).HeaderCell.GetPreferredSize(rowIndexTmp).Width); 2467cursorClip.Width = Math.Min(frozenWidth, _layout.Data.Width); 2481cursorClip.Width = Math.Min(scrollingWidth, _layout.Data.Width); 2984r.X = Math.Max(inside.Left, r.X); 2985r.X = Math.Min(r.X, inside.Right - r.Width); 2994r.X = Math.Min(inside.Right - r.Width, r.X); 2995r.X = Math.Max(r.X, inside.Left); 3011r.X = Math.Max(inside.Left, r.X); 3015r.X = Math.Min(inside.Right - 3, r.X); 3016r.X = Math.Max(r.X, 0); 3030r.Y = Math.Min(inside.Bottom - 3, r.Y); 3031r.Y = Math.Max(r.Y, 0); 4391colHeaders.Height = Math.Min(_columnHeadersHeight, colHeaders.Height); 4405rowHeaders.Width = Math.Min(RowHeadersWidth, rowHeaders.Width); 4424topLeft.Width = Math.Min(RowHeadersWidth, topLeft.Width); 4545int oldThumbHeight = Math.Max(((_vertScrollBar.Height - 2 * SystemInformation.VerticalScrollBarArrowHeight) * _vertScrollBar.LargeChange) / _vertScrollBar.Maximum, 8); 4555|| oldThumbHeight != Math.Max( 5665? Math.Max( 5668: Math.Min( 5789if (Math.Abs(dgvcme.X - _lastMouseClickInfo.X) <= hotDoubleClickZone.Width / 2 5790&& Math.Abs(dgvcme.Y - _lastMouseClickInfo.Y) <= hotDoubleClickZone.Height / 2) 6052int y = Math.Min(e.Y + _mouseBarOffset, _layout.Data.Bottom - 1); 6116newX = Math.Max(x + _mouseBarOffset, _layout.Data.X); 6121newX = Math.Min(x + _mouseBarOffset, _layout.Data.Right - 1); 6299x = Math.Max(e.X + _mouseBarOffset, _layout.Data.Left - 1); 6304x = Math.Min(e.X + _mouseBarOffset, _layout.Data.Right - 1); 6331int y = Math.Min(e.Y + _mouseBarOffset, _layout.Data.Bottom - 1); 6336proposedHeight = Math.Max(proposedHeight, minimumHeight); 8443return Math.Max(1, 4000 / xOffset); 8572int emptyBackgroundWidth = Math.Max(0, _layout.Data.Width - Columns.GetColumnsWidth(DataGridViewElementStates.Visible)); 8573int emptyBackgroundHeight = Math.Max(0, _layout.Data.Height - frozenVisibleRowsHeight - trailingScrollingRowsHeight); 8999int preferredWidth = Math.Min(minimumWidth + Columns.GetColumnsWidth(DataGridViewElementStates.Visible), proposedConstraints.Width); 9016int preferredHeight = Math.Min(minimumHeight + Rows.GetRowsHeight(DataGridViewElementStates.Visible), proposedConstraints.Height); 9190return Math.Max(1, 600 / yOffset); 9642int absXOffset = Math.Abs(xOffset), normOffset = xOffset / absXOffset; 9659ptMouse.Y - yOffset - (yOffset / Math.Abs(yOffset))) 10322_horizScrollBar.LargeChange = Math.Max(totalVisibleWidth - totalVisibleFrozenWidth - widthNotVisible, 0); 11203dataGridViewColumn.ThicknessInternal = Math.Max(dataGridViewColumn.MinimumWidth, dataGridViewColumn.CachedThickness); 11282dataGridViewColumn.ThicknessInternal = Math.Max(dataGridViewColumn.MinimumWidth, dataGridViewColumn.CachedThickness); 12703if (Math.Abs(_ptMouseDownGridCoord.X - ptGridCoord.X) >= s_dragSize.Width 12704|| Math.Abs(_ptMouseDownGridCoord.Y - ptGridCoord.Y) >= s_dragSize.Height) 14410dataGridViewColumn.ThicknessInternal = Math.Max(dataGridViewColumn.MinimumWidth, dataGridViewColumn.CachedThickness); 16285HorizScrollTimer.Interval = GetColumnScrollRate(Math.Abs(xOffset)); 16300VertScrollTimer.Interval = GetRowScrollRate(Math.Abs(yOffset)); 16526if (Math.Abs(VerticalOffset - originalVerticalOffset) >= Math.Abs(fullNotches * _vertScrollBar.LargeChange)) 16539if (Math.Abs(HorizontalOffset - originalHorizontalOffset) >= Math.Abs(fullNotches * _horizScrollBar.LargeChange)) 16628absScrollBands = Math.Abs(scrollBands); 16935dataGridViewColumn.ThicknessInternal = Math.Max(dataGridViewColumn.MinimumWidth, dataGridViewColumn.CachedThickness); 16989dataGridViewRow.ThicknessInternal = Math.Max(dataGridViewRow.MinimumHeight, dataGridViewRow.CachedThickness); 17712rowIndex = Math.Min(rowIndex, Rows.Count - 1); 18654dataGridViewRow.ThicknessInternal = Math.Max(dataGridViewRow.MinimumHeight, dataGridViewRow.CachedThickness); 19844editingZone.Width = Math.Max(0, editingZone.Width - totalVisibleFrozenWidth); 28465VerticalOffset += Math.Max(firstDisplayedScrollingRowHeight, _vertScrollBar.LargeChange); 29883int absYOffset = Math.Abs(yOffset), normOffset = yOffset / absYOffset; 29902? HitTest(ptMouse.X - xOffset - (xOffset / Math.Abs(xOffset)), ptMouse.Y - yOffset - normOffset)
System\Windows\Forms\Controls\DataGridView\DataGridViewButtonCell.cs (2)
394preferredSize.Width = Math.Max(preferredSize.Width, borderAndPaddingWidths + IconMarginWidth * 2 + s_iconsWidth); 404preferredSize.Height = Math.Max(preferredSize.Height, borderAndPaddingHeights + IconMarginHeight * 2 + s_iconsHeight);
System\Windows\Forms\Controls\DataGridView\DataGridViewCellStyle.cs (4)
275value.Left = Math.Max(0, value.Left); 276value.Right = Math.Max(0, value.Right); 277value.Top = Math.Max(0, value.Top); 278value.Bottom = Math.Max(0, value.Bottom);
System\Windows\Forms\Controls\DataGridView\DataGridViewCheckBoxCell.cs (2)
743preferredSize.Width = Math.Max(preferredSize.Width, 749preferredSize.Height = Math.Max(preferredSize.Height,
System\Windows\Forms\Controls\DataGridView\DataGridViewColumnHeaderCell.cs (7)
521Math.Max(1, constraintSize.Height - borderAndPaddingHeights - 2 * VerticalMargin), 549preferredSize.Width = Math.Max(preferredSize.Width, 1); 622preferredSize.Height = Math.Max(preferredSize.Height, glyphSize.Height); 623preferredSize.Height = Math.Max(preferredSize.Height, 1); 664preferredSize.Height = Math.Max(preferredSize.Height, s_sortGlyphHeight); 667preferredSize.Width = Math.Max(preferredSize.Width, 1); 668preferredSize.Height = Math.Max(preferredSize.Height, 1);
System\Windows\Forms\Controls\DataGridView\DataGridViewComboBoxCell.cs (7)
543dropHeight = Math.Min(GetDropDownButtonHeight(screen, cellStyle), adjustedSize.Height - 2); 546int dropWidth = Math.Min(SystemInformation.HorizontalScrollBarThumbWidth, adjustedSize.Width - 2 * Margin - 1); 1201preferredSize.Width = Math.Max( 1222preferredSize.Height = Math.Max(preferredSize.Height, borderAndPaddingHeights + IconMarginHeight * 2 + s_iconsHeight); 1992int dropWidth = Math.Min(SystemInformation.HorizontalScrollBarThumbWidth, valBounds.Width - 2 * Margin - 1); 1999dropHeight = Math.Min(GetDropDownButtonHeight(g, cellStyle), paintPostXPThemes ? valBounds.Height : valBounds.Height - 2); 2003dropHeight = Math.Min(GetDropDownButtonHeight(g, cellStyle), valBounds.Height - 4);
System\Windows\Forms\Controls\DataGridView\DataGridViewImageCell.cs (6)
435preferredSize = new Size(0, Math.Min(img.Height, decimal.ToInt32((decimal)img.Height * imgWidthAllowed / img.Width))); 447preferredSize = new Size(0, Math.Min(ico.Height, decimal.ToInt32((decimal)ico.Height * icoWidthAllowed / ico.Width))); 470preferredSize = new Size(Math.Min(img.Width, decimal.ToInt32((decimal)img.Width * imgHeightAllowed / img.Height)), 0); 482preferredSize = new Size(Math.Min(ico.Width, decimal.ToInt32((decimal)ico.Width * icoHeightAllowed / ico.Height)), 0); 522preferredSize.Width = Math.Max(preferredSize.Width, borderAndPaddingWidths + IconMarginWidth * 2 + s_iconsWidth); 532preferredSize.Height = Math.Max(preferredSize.Height, borderAndPaddingHeights + IconMarginHeight * 2 + s_iconsHeight);
System\Windows\Forms\Controls\DataGridView\DataGridViewLinkCell.cs (4)
579Math.Max(1, maxHeight), 593Math.Max(1, constraintSize.Width - borderAndPaddingWidths - HorizontalTextMarginLeft - HorizontalTextMarginRight), 648preferredSize.Width = Math.Max(preferredSize.Width, borderAndPaddingWidths + IconMarginWidth * 2 + s_iconsWidth); 663preferredSize.Height = Math.Max(preferredSize.Height, borderAndPaddingHeights + IconMarginHeight * 2 + s_iconsHeight);
System\Windows\Forms\Controls\DataGridView\DataGridViewRow.cs (2)
1298preferredRowThickness = Math.Max(preferredRowThickness, HeaderCell.GetPreferredHeight(rowIndex, DataGridView.RowHeadersWidth)); 1302preferredRowThickness = Math.Max(preferredRowThickness, HeaderCell.GetPreferredSize(rowIndex).Height);
System\Windows\Forms\Controls\DataGridView\DataGridViewTextBoxCell.cs (11)
154editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - DATAGRIDVIEWTEXTBOXCELL_horizontalTextOffsetLeft - 2); 159editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - DATAGRIDVIEWTEXTBOXCELL_horizontalTextOffsetLeft - 1); 168editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - 3); 178editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - DATAGRIDVIEWTEXTBOXCELL_horizontalTextOffsetRight); 183editingControlBounds.Width = Math.Max(0, editingControlBounds.Width - DATAGRIDVIEWTEXTBOXCELL_horizontalTextOffsetRight - 1); 195editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - DATAGRIDVIEWTEXTBOXCELL_verticalTextOffsetTop); 207editingControlBounds.Height = Math.Max(0, editingControlBounds.Height - DATAGRIDVIEWTEXTBOXCELL_verticalTextOffsetBottom); 425Math.Max(1, constraintSize.Height - borderAndPaddingHeights - DATAGRIDVIEWTEXTBOXCELL_verticalTextMarginTopWithWrapping - DATAGRIDVIEWTEXTBOXCELL_verticalTextMarginBottom), 439Math.Max(1, constraintSize.Width - borderAndPaddingWidths - DATAGRIDVIEWTEXTBOXCELL_horizontalTextMarginLeft - DATAGRIDVIEWTEXTBOXCELL_horizontalTextMarginRight), 490preferredSize.Width = Math.Max(preferredSize.Width, borderAndPaddingWidths + IconMarginWidth * 2 + s_iconsWidth); 501preferredSize.Height = Math.Max(preferredSize.Height, borderAndPaddingHeights + IconMarginHeight * 2 + s_iconsHeight);
System\Windows\Forms\Controls\DataGridView\DataGridViewUtilities.cs (3)
200preferredWidth = Math.Max(preferredWidth, 1); 255return new Size(0, Math.Max(minHeightIcon, minHeightContent) + borderAndPaddingHeights); 293preferredSize.Height = Math.Max(preferredSize.Height,
System\Windows\Forms\Controls\GroupBox\GroupBox.cs (3)
166Math.Max(size.Width - padding.Horizontal, 0), 167Math.Max(size.Height - _fontHeight - padding.Vertical, 0)); 541int textRight = Math.Min(textLeft + textSize.Width, Width - 6);
System\Windows\Forms\Controls\GroupBox\GroupBoxRenderer.cs (1)
218clipMiddle.Width = Math.Max(0, textBounds.Width - 3); // -3 to account for the margin built in the MeasureText result
System\Windows\Forms\Controls\ImageList\ImageList.cs (1)
564int length = Math.Abs(targetData.Stride);
System\Windows\Forms\Controls\Labels\LinkLabel.cs (3)
637int length = Math.Min(link.Length, textLen - link.Start); 1680int maxStart = Math.Max(left.Start, right.Start); 1681int minEnd = Math.Min(left.Start + left.Length, right.Start + right.Length);
System\Windows\Forms\Controls\Labels\LinkUtilities.cs (1)
44int nMax = Math.Min(rgb.Length, rgbsCount);
System\Windows\Forms\Controls\ListBoxes\CheckedListBox.cs (2)
532int centeringFactor = Math.Max((height - _idealCheckSize) / 2, 0); 646if (Math.Abs(tabOffset) < tabDistance)
System\Windows\Forms\Controls\ListBoxes\ListBox.cs (7)
1308return Math.Max(oldMax, textSize.Width); 1416ArgumentOutOfRangeException.ThrowIfGreaterThanOrEqual(index, Math.Max(1, itemCount)); 1578return actualLength == PInvoke.LB_ERR ? string.Empty : buffer[..Math.Min(maxLength, actualLength)].ToString(); 2282width = (int)(Math.Ceiling(graphics.MeasureString(GetItemText(item), Font).Width)); 2357bounds.Width = MultiColumn ? Math.Max(ColumnWidth, bounds.Width) : Math.Max(MaxItemWidth, bounds.Width); 2482Height = Math.Max(Height, ItemHeight);
System\Windows\Forms\Controls\ListBoxes\ListBox.IntegerCollection.cs (2)
210_innerArray = new int[Math.Max(elements, 4)]; 214int newLength = Math.Max(_innerArray.Length * 2, _innerArray.Length + elements);
System\Windows\Forms\Controls\ListView\ColumnHeader.cs (2)
131int lowDI = Math.Min(DisplayIndexInternal, value); 132int hiDI = Math.Max(DisplayIndexInternal, value);
System\Windows\Forms\Controls\ListView\ListView.cs (13)
1886topIndex = Math.Min(topIndex, VirtualListSize - 1); 3243x = Math.Max(itemBounds.Left, iconBounds.Left); 3244y = Math.Max(itemBounds.Top, iconBounds.Top) - 1; 3247x = Math.Max(itemBounds.Left, iconBounds.Left); 3248y = Math.Max(itemBounds.Top, iconBounds.Top) + 1; 3251x = Math.Max(itemBounds.Left, iconBounds.Left) - 1; 3252y = Math.Max(itemBounds.Top, iconBounds.Top); 3255x = Math.Max(itemBounds.Left, iconBounds.Left) + 1; 3256y = Math.Max(itemBounds.Top, iconBounds.Top); 4129cColumns = (uint)(_columnHeaders is not null ? Math.Min(MAXTILECOLUMNS, _columnHeaders.Length) : 0), 6210int lowDI = Math.Min(from, to); 6211int hiDI = Math.Max(from, to); 6828Marshal.Copy(charBuf, 0, destPtr, Math.Min(charBuf.Length, infoTip->cchTextMax));
System\Windows\Forms\Controls\ListView\ListViewGroup.ListViewGroupAccessibleObject.cs (4)
70groupRect.top = Math.Max(listViewBounds.Top, groupRect.top); 71groupRect.bottom = Math.Min(listViewBounds.Bottom, groupRect.bottom); 72groupRect.left = Math.Max(listViewBounds.Left, groupRect.left); 73groupRect.right = Math.Min(listViewBounds.Right, groupRect.right);
System\Windows\Forms\Controls\ListView\ListViewItem.IKeyboardToolTip.cs (3)
114new Size(Math.Min(TextRenderer.MeasureText(item.Text, item.Font).Width, itemBounds.Width), 128textWidth = Math.Max(TextRenderer.MeasureText(subItem.Text, subItem.Font).Width, textWidth); 131return new Rectangle(point, new Size(Math.Min(textWidth, itemBounds.Width), itemBounds.Height));
System\Windows\Forms\Controls\ListView\ListViewItem.ListViewItemTileAccessibleObject.cs (1)
109int subItemCount = Math.Min(_owningListView.Columns.Count, _owningItem.SubItems.Count);
System\Windows\Forms\Controls\Menus\MenuTimer.cs (1)
23_slowShow = Math.Max(_quickShow, SystemInformation.MenuShowDelay);
System\Windows\Forms\Controls\MonthCalendar\MonthCalendar.MonthCalendarAccessibleObject.cs (1)
540? (int)Math.Ceiling((double)CalendarsAccessibleObjects.Count / ColumnCount)
System\Windows\Forms\Controls\PictureBox\PictureBox.cs (1)
368float ratio = Math.Min(ClientRectangle.Width / (float)imageSize.Width, ClientRectangle.Height / (float)imageSize.Height);
System\Windows\Forms\Controls\PropertyGrid\PropertyGrid.cs (13)
1929if (Math.Abs(gridBottom - y) <= 1 && y > gridTop) 1960y = Math.Min((rectTarget.Y + rectTarget.Height - 15), y); 1963return Math.Max(DividerLimitHigh(target), y); 2582int sx = (int)Math.Round(Left * dx); 2583int sy = (int)Math.Round(Top * dy); 2584int sw = (int)Math.Round((Left + Width) * dx - sx); 2585int sh = (int)Math.Round((Top + Height) * dy - sy); 2698height = Math.Min(helpRequestedHeight, maxSpace); 2708height = Math.Min(helpRequestedHeight, maxSpace / 2 - 1); 2711height = Math.Max(height, s_cyDivider * 2); 2738height = Math.Min(commandsRequestedHeight, maxSpace); 2746height = Math.Max(height, s_cyDivider * 2); 2830size.Height = Math.Max(0, yNew);
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\GridEntry.cs (1)
1576int maxSpace = Math.Min(rect.Width - stringX - 1, labelWidth + PropertyGridView.GdiPlusSpace);
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\GridErrorDialog.cs (2)
302int detailsWidth = (int)Math.Ceiling(sizef.Width); 304_detailsButton.Width = (int)Math.Ceiling(detailsWidth * (_ownerGrid.UseCompatibleTextRendering ? 1.15f : 1.4f));
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\HelpPane.cs (6)
94return Math.Max(height + 2 * padding, isScalingRequirementMet ? LogicalToDeviceUnits(LogicalDefaultHeight) : LogicalDefaultHeight); 151size.Width = Math.Max(0, size.Width - 2 * _borderSize); 152size.Height = Math.Max(0, size.Height - 2 * _borderSize); 158Math.Min(_lineHeight, size.Height), 165Math.Max(0, size.Height - _lineHeight - (ScaleHelper.IsScalingRequirementMet ? LogicalToDeviceUnits(1) : 1)), 209int lines = Math.Max(MinimumLines, newHeight / _lineHeight);
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\PropertyGridView.cs (30)
400set => _requiredLabelPaintMargin = (short)Math.Max(Math.Max(value, _requiredLabelPaintMargin), GdiPlusSpace); 1421size.Width = Math.Max(rect.Width + 1, size.Width); 1423location.X = Math.Min( 1425Math.Max(rectScreen.X, location.X + rect.X + rect.Width - size.Width)); 2101int pos = Math.Max(Math.Min(xPosition, widthPS - 10), OutlineIconSize * 2); 2596if (Math.Abs(screenPoint.X - _rowSelectPos.X) < SystemInformation.DoubleClickSize.Width && 2597Math.Abs(screenPoint.Y - _rowSelectPos.Y) < SystemInformation.DoubleClickSize.Height) 3175int newOffset = Math.Max(0, initialOffset - large); 3176newOffset = Math.Min(newOffset, TotalProperties - _visibleRows + 1); 3179if (Math.Abs(initialOffset - originalOffset) >= Math.Abs(fullNotches * _scrollBar.LargeChange)) 3208int newOffset = Math.Max(0, initialOffset - scrollBands); 3209newOffset = Math.Min(newOffset, TotalProperties - _visibleRows + 1); 3275startRow = Math.Max(0, startPosition.Y); 3283int visibleCount = Math.Min(TotalProperties - GetScrollOffset(), 1 + _visibleRows); 3299visibleCount = Math.Min(visibleCount, endRow + 1); 3708maxWidth = Math.Max(textSize.Width, maxWidth); 3724DropDownListBox.Height = Math.Max(tm.tmHeight + 2, Math.Min(_maxListBoxHeight, DropDownListBox.PreferredHeight)); 3725DropDownListBox.Width = Math.Max(maxWidth, GetRectangle(row, RowValue).Width); 4208int maxRows = (int)Math.Ceiling(((double)GetOurSize().Height) / (1 + RowHeight)); 4423_visibleRows = (int)Math.Ceiling(((double)size.Height) / (1 + RowHeight)); 4429_labelRatio = Math.Max(Math.Min(_labelRatio, 9), 1.1); 4549int newPosition = Math.Max(0, Math.Min(TotalProperties - _visibleRows + 1, offset)); 4821ScrollBar.Maximum = Math.Max(0, TotalProperties - 1); 5036private bool SplitterInside(int x) => Math.Abs(x - LabelWidth) < 4;
System\Windows\Forms\Controls\PropertyGrid\PropertyGridInternal\PropertyGridView.DropDownHolder.cs (4)
375else if (!_resizeUp && Math.Abs(Height - y) < s_resizeBorderSize) 379else if (_resizeUp && Math.Abs(y) < s_resizeBorderSize) 435newBounds.Height = Math.Max(s_minDropDownSize.Height, _dragBaseRect.Height + (dragPoint.Y - _dragStart.Y)); 591listBox.Height = Math.Max(listBox.Height, listBox.ItemHeight);
System\Windows\Forms\Controls\RichTextBox\RichTextBox.cs (4)
2036txrg.chrg.cpMax = Math.Min(txrg.chrg.cpMax, end); 2227index = Math.Max(t.Length - 1, 0); 2677numerator = (int)Math.Ceiling(multiplier); 2680numerator = (int)Math.Floor(multiplier);
System\Windows\Forms\Controls\Splitter\Splitter.cs (2)
798return Math.Max(Math.Min(size, _maxSize), _minSize);
System\Windows\Forms\Controls\TextBox\TextBoxBase.cs (6)
853textSize.Height = Math.Max(textSize.Height, FontHeight); 886start = Math.Max(0, start); 888end = Math.Max(0, end); 1194Height = Math.Max(saveHeight, PreferredHeight + 2); // 2 = fudge factor 1565index = Math.Max(t.Length - 1, 0); 1701long longLength = Math.Min(0, (long)length + start - textLen);
System\Windows\Forms\Controls\TextBox\TextBoxBase.TextBoxBaseUiaTextProvider.cs (5)
126clientLocation.X = Math.Max(clientLocation.X, clientRectangle.left); 127clientLocation.X = Math.Min(clientLocation.X, clientRectangle.right); 128clientLocation.Y = Math.Max(clientLocation.Y, clientRectangle.top); 129clientLocation.Y = Math.Min(clientLocation.Y, clientRectangle.bottom); 259return fontHeight != 0 ? (int)Math.Ceiling(((double)rect.Height) / fontHeight) : 0;
System\Windows\Forms\Controls\ToolStrips\StatusStrip.cs (5)
212int gripHeight = Math.Min(DefaultSize.Height, statusStripSize.Height); 495TableLayoutSettings.RowStyles[0].Height = Math.Max(0, DisplayRectangle.Height); 543TableLayoutSettings.ColumnStyles[0].Width = Math.Max(0, DisplayRectangle.Width); 591int deltaBottomEdge = Math.Abs(rootHwndClientArea.bottom - gripLocation.Y); 592int deltaRightEdge = Math.Abs(rootHwndClientArea.right - gripLocation.X);
System\Windows\Forms\Controls\ToolStrips\ToolStrip.cs (11)
2171double hypotenuse = Math.Sqrt(adjacentSide * adjacentSide + oppositeSide * oppositeSide); 2181double tan = Math.Abs(Math.Atan(oppositeSide / adjacentSide)); 2184minTan = Math.Min(minTan, tan); 2185minHypotenuse = Math.Min(minHypotenuse, hypotenuse); 2274maxSize.Height = Math.Max(0, defaultSize.Height); 2291maxSize.Height = Math.Max(maxSize.Height, itemMargin.Vertical + prefItemSize.Height); 2350maxSize.Width = Math.Max(maxSize.Width, itemMargin.Horizontal + preferredSize.Width); 2881startIndex = Math.Max(0, startIndex); 4176gripRectangle.X = Math.Max(0, displayRect.X - Grip.GripThickness); 4177gripRectangle.Y = Math.Max(0, displayRect.Top - Grip.Margin.Top);
System\Windows\Forms\Controls\ToolStrips\ToolStripButton.cs (1)
162prefSize.Width = Math.Max(prefSize.Width, _standardButtonWidth);
System\Windows\Forms\Controls\ToolStrips\ToolStripComboBox.cs (1)
325preferredSize.Width = Math.Max(preferredSize.Width, 75);
System\Windows\Forms\Controls\ToolStrips\ToolStripDropDown.cs (2)
571value = Math.Clamp(value, 0.0d, 1.0d); 1888_countDropDownItemsAssignedTo = Math.Max(--_countDropDownItemsAssignedTo, 0);
System\Windows\Forms\Controls\ToolStrips\ToolStripDropDownMenu.cs (16)
299menuItemTextSize.Height = Math.Max(menuItemTextSize.Height, shortcutTextSize.Height); 303maxTextSize.Width = Math.Max(maxTextSize.Width, menuItemTextSize.Width); 304maxTextSize.Height = Math.Max(maxTextSize.Height, menuItemTextSize.Height); 313maxImageSize.Width = Math.Max(maxImageSize.Width, imageSize.Width); 314maxImageSize.Height = Math.Max(maxImageSize.Height, imageSize.Height); 319maxCheckSize.Width = Math.Max(checkedImageSize.Width, maxCheckSize.Width); 320maxCheckSize.Height = Math.Max(checkedImageSize.Height, maxCheckSize.Height); 325maxNonMenuItemSize.Height = Math.Max(item.Bounds.Height, maxNonMenuItemSize.Height); 326maxNonMenuItemSize.Width = Math.Max(item.Bounds.Width, maxNonMenuItemSize.Width); 330_maxItemSize.Height = Math.Max(maxTextSize.Height + _textPadding.Vertical, Math.Max(maxCheckSize.Height + _checkPadding.Vertical, maxArrowSize.Height + _arrowPadding.Vertical)); 335_maxItemSize.Height = Math.Max(maxImageSize.Height + _imagePadding.Vertical, _maxItemSize.Height); 346maxTextSize.Width = Math.Max(maxTextSize.Width, maxNonMenuItemSize.Width); 351int extraImageWidth = Math.Max(0, maxImageSize.Width - _defaultImageSize.Width); 839minY = Math.Min(minY, item.Bounds.Top); 840maxY = Math.Max(maxY, item.Bounds.Bottom);
System\Windows\Forms\Controls\ToolStrips\ToolStripManager.cs (4)
401if (nextControl is not null && Math.Abs(nextControl.TabIndex - startTabIndex) <= 1) 1230int insertIndex = Math.Min(destinationItems.Count, source.MergeIndex); 1336historyItem.PreviousIndexCollection!.Insert(Math.Min(historyItem.PreviousIndex, historyItem.PreviousIndexCollection.Count), historyItem.TargetItem!); 1339historyItem.IndexCollection!.Insert(Math.Min(historyItem.Index, historyItem.IndexCollection.Count), historyItem.TargetItem!);
System\Windows\Forms\Controls\ToolStrips\ToolStripMenuItem.cs (1)
1076rect.X = Math.Max(rect.X, 0);
System\Windows\Forms\Controls\ToolStrips\ToolStripOverflowButton.cs (2)
78preferredSize.Width = Math.Min(constrainingSize.Width, s_maxSize); 82preferredSize.Height = Math.Min(constrainingSize.Height, s_maxSize);
System\Windows\Forms\Controls\ToolStrips\ToolStripPanelRow.cs (4)
443cachedBounds.X -= Math.Max(0, margins[i] - c.Margin.Left); 475cellOffsets[j] += Math.Max(0, currentCell.CachedBounds.Width - cachedBounds.Width); 540cachedBounds.X = Math.Max(0, cachedBounds.X - margins[i] - c.Margin.Top); 572cellOffsets[j] += Math.Max(0, currentCell.CachedBounds.Height - cachedBounds.Height);
System\Windows\Forms\Controls\ToolStrips\ToolStripPanelRow.HorizontalRowManager.cs (4)
136return requiredSpace - Math.Max(0, spaceToFree); 481nextCellMargin.Left = Math.Max(0, nextCellMargin.Left - freedSpace); 496lastCellMargin.Left = Math.Max(0, locationToDrag.X - nextCell.Bounds.Right); 543cellMargin.Left = Math.Max(0, locationToDrag.X - Row.Margin.Left);
System\Windows\Forms\Controls\ToolStrips\ToolStripPanelRow.VerticalRowManager.cs (3)
138return requiredSpace - Math.Max(0, spaceToFree); 506lastCellMargin.Top = Math.Max(0, locationToDrag.Y - nextCell.Bounds.Bottom); 547cellMargin.Top = Math.Max(0, locationToDrag.Y - Row.Margin.Top);
System\Windows\Forms\Controls\ToolStrips\ToolstripProfessionalRenderer.cs (1)
1465bounds.Height = Math.Max(0, bounds.Height - 6);
System\Windows\Forms\Controls\ToolStrips\ToolStripSplitButton.cs (3)
301Rectangle dropDownButtonBounds = new(Point.Empty, new Size(Math.Min(Width, DropDownButtonWidth), Height)); 304int splitButtonButtonWidth = Math.Max(0, Width - dropDownButtonBounds.Width); 305int splitButtonButtonHeight = Math.Max(0, Height);
System\Windows\Forms\Controls\ToolStrips\ToolStripSplitStackDragDropHandler.cs (4)
85int insertIndex = Math.Max(0, toolStripItemIndex); 102insertIndex = Math.Max(0, (_owner.RightToLeft == RightToLeft.Yes) ? insertIndex + 1 : insertIndex); 110insertIndex = Math.Max(0, (_owner.RightToLeft == RightToLeft.No) ? insertIndex + 1 : insertIndex); 121_owner.Items.MoveItem(Math.Max(0, insertIndex), droppedItem);
System\Windows\Forms\Controls\ToolStrips\ToolStripSplitStackLayout.cs (2)
334itemSize.Height = Math.Max(_displayRectangle.Height - itemMargin.Vertical, 0); 467itemSize.Width = Math.Max(toolStripPreferredSize.Width - itemMargin.Horizontal - 1, 0);
System\Windows\Forms\Controls\ToolStrips\ToolStripSystemRenderer.cs (1)
291bounds.Y = Math.Max(0, (e.GripBounds.Height - bounds.Height - 2/*number of pixels for border*/) / 2);
System\Windows\Forms\Controls\TrackBar\TrackBar.cs (2)
959Value = Math.Min(absScrollBands + Value, Maximum); 965Value = Math.Max(Value - absScrollBands, Minimum);
System\Windows\Forms\Controls\TrackBar\TrackBarRenderer.cs (2)
130t_visualStyleRenderer.DrawEdge(g, new Rectangle((int)Math.Round(x), bounds.Y, LineWidth, bounds.Height), Edges.Left, edgeStyle, EdgeEffects.None); 160t_visualStyleRenderer.DrawEdge(g, new Rectangle(bounds.X, (int)Math.Round(y), bounds.Width, LineWidth), Edges.Top, edgeStyle, EdgeEffects.None);
System\Windows\Forms\Controls\TreeView\TreeNode.cs (1)
2213iImage = Math.Max(
System\Windows\Forms\Controls\TreeView\TreeView.cs (3)
545return Math.Max(0, _imageList.Images.Count - 1); 787return Math.Max(16, FontHeight + 3); 1016return Math.Max(0, _imageList.Images.Count - 1);
System\Windows\Forms\Controls\UpDown\NumericUpDown.cs (7)
774int numDigits = (int)Math.Floor(Math.Log(Math.Max(-(double)Minimum, (double)Maximum), baseSize)); 778maxDigits = (int)Math.Floor(Math.Log(long.MaxValue, baseSize)); 782maxDigits = (int)Math.Floor(Math.Log((double)decimal.MaxValue, baseSize));
System\Windows\Forms\DataBinding\Command.cs (1)
76icmdLim = Math.Min(IdLim - IdMin, 2 * icmd);
System\Windows\Forms\DataBinding\CurrencyManager.cs (3)
372listposition = Math.Min(newPosition, Count - 1); 690ChangeRecordState(Math.Min(listposition, _list.Count - 1), true, false, true, false); 742ChangeRecordState(Math.Min(listposition, Count - 1), true, false, true, false);
System\Windows\Forms\Dialogs\CommonDialogs\ColorDialog.cs (1)
87MemoryMarshal.Cast<int, COLORREF>(value)[..Math.Min(customColors.Length, value.Length)].CopyTo(customColors);
System\Windows\Forms\Dialogs\TaskDialog\TaskDialog.cs (1)
1100_buttonClickNavigationCounter.navigationIndex = Math.Min(
System\Windows\Forms\Dialogs\ThreadExceptionDialog.cs (3)
234int buttonTop = Math.Max(textSize.Height, _scaledMaxTextHeight) + _scaledPaddingHeight; 265_scaledMessageTopPadding + (_scaledMaxTextHeight - Math.Min(textSize.Height, _scaledMaxTextHeight)) / 2, 349_scaledHeightPadding = (int)Math.Round(HEIGHTPADDING * ((float)e.DeviceDpiNew / e.DeviceDpiOld));
System\Windows\Forms\Form.cs (17)
449return new Size((int)Math.Round(real.Width), (int)Math.Round(real.Height)); 1243Size = new Size(Math.Min(size.Width, value.Width), Math.Min(size.Height, value.Height)); 1360Size = new Size(Math.Max(size.Width, value.Width), Math.Max(size.Height, value.Height)); 1576value = Math.Clamp(value, 0.0d, 1.0d); 2984Size newVar = new((int)Math.Round(newVarF.Width), (int)Math.Round(newVarF.Height)); 3652cp.X = Math.Max(clientRect.X, clientRect.X + (clientRect.Width - cp.Width) / 2); 3653cp.Y = Math.Max(clientRect.Y, clientRect.Y + (clientRect.Height - cp.Height) / 2); 3677cp.X = Math.Max(screenRect.X, screenRect.X + (screenRect.Width - cp.Width) / 2); 3678cp.Y = Math.Max(screenRect.Y, screenRect.Y + (screenRect.Height - cp.Height) / 2); 3914p.X = Math.Max(screenRect.X, screenRect.X + (screenRect.Width - Width) / 2); 3915p.Y = Math.Max(screenRect.Y, screenRect.Y + (screenRect.Height - Height) / 2); 6812mmi->ptMaxTrackSize.X = Math.Max(maxTrack.Width, minTrackWindowSize.Width); 6813mmi->ptMaxTrackSize.Y = Math.Max(maxTrack.Height, minTrackWindowSize.Height);
System\Windows\Forms\Internal\WinFormsUtils.cs (2)
82bounds.Size = new Size(Math.Min(constrainingBounds.Width - 2, bounds.Width), 83Math.Min(constrainingBounds.Height - 2, bounds.Height));
System\Windows\Forms\Layout\CommonProperties.cs (4)
207bounds.Width = Math.Min(bounds.Width, value.Width); 208bounds.Height = Math.Min(bounds.Height, value.Height); 231bounds.Width = Math.Max(bounds.Width, value.Width); 232bounds.Height = Math.Max(bounds.Height, value.Height);
System\Windows\Forms\Layout\Containers\ContainerControl.cs (1)
743retval.Width = (int)Math.Round(size.Width / ((float)FontMeasureString.Length));
System\Windows\Forms\Layout\Containers\SplitContainer.cs (27)
955_splitterDistance = (_splitterDistance < Panel1MinSize) ? _splitterDistance + SplitterIncrement : Math.Max(_splitterDistance, _borderSize); 1092x = Math.Max(Math.Min(x, Width - Panel2MinSize), Panel1MinSize); 1093y = Math.Max(y, 0); 1097y = Math.Max(Math.Min(y, Height - Panel2MinSize), Panel1MinSize); 1098x = Math.Max(x, 0); 1507size = Math.Max(Panel1.Width + delta, _borderSize); 1512size = Math.Max(Panel1.Width - delta, _borderSize); 1517size = Math.Max(Panel1.Height + delta, _borderSize); 1523return Math.Max(Math.Min(size, Width - Panel2MinSize), Panel1MinSize); 1527return Math.Max(Math.Min(size, Height - Panel2MinSize), Panel1MinSize); 1620Panel2.Size = new Size(Math.Max(Width - _panelSize - SplitterWidthInternal, Panel2MinSize), Height); 1626_splitterDistance = Math.Max(Width - _panelSize - SplitterWidthInternal, Panel1MinSize); 1635_splitterDistance = Math.Max((int)(Math.Floor(Width / _ratioWidth)), Panel1MinSize); 1640Panel2.Size = new Size(Math.Max(Width - _splitterDistance - SplitterWidthInternal, Panel2MinSize), Height); 1679Panel2.Size = new Size(Width, Math.Max(Height - panel2Start, Panel2MinSize)); 1686_splitterDistance = Math.Max(Height - Panel2.Height - SplitterWidthInternal, Panel1MinSize); 1698_splitterDistance = Math.Max((int)(Math.Floor(Height / _ratioHeight)), Panel1MinSize); 1704Panel2.Size = new Size(Width, Math.Max(Height - panel2Start, Panel2MinSize)); 1768SplitterWidth = (int)Math.Round(SplitterWidth * scale); 1769_splitterDistance = (int)Math.Round(_splitterDistance * scale); 1775_panelSize = (int)Math.Round(_panelSize * scale);
System\Windows\Forms\Layout\DefaultLayout.cs (28)
306left = Math.Max(Math.Abs(left), Math.Abs(cachedBounds.Left)); 309right = left + Math.Max(element.Bounds.Width, cachedBounds.Width) + Math.Abs(right); 314right = right > 0 ? right : element.Bounds.Right + Math.Abs(right); 324top = Math.Max(Math.Abs(top), Math.Abs(cachedBounds.Top)); 327bottom = top + Math.Max(element.Bounds.Height, cachedBounds.Height) + Math.Abs(bottom); 332bottom = bottom > 0 ? bottom : element.Bounds.Bottom + Math.Abs(bottom); 489Math.Max(0, newElementBounds.Width - remainingBounds.Width), 490Math.Max(0, newElementBounds.Height - remainingBounds.Height)); 546newSize.Width = Math.Max(newSize.Width, remainingSize.Width); 563newSize.Height = Math.Max(newSize.Height, remainingSize.Height); 994anchorInfo.Left = (int)Math.Round(anchorInfo.Left * widthFactor); 995anchorInfo.Top = (int)Math.Round(anchorInfo.Top * heightFactor); 996anchorInfo.Right = (int)Math.Round(anchorInfo.Right * widthFactor); 997anchorInfo.Bottom = (int)Math.Round(anchorInfo.Bottom * heightFactor); 1130prefSize.Width = Math.Max(prefSize.Width, elementSpace.Right); 1137prefSize.Height = Math.Max(prefSize.Height, elementSpace.Bottom); 1148prefSize.Width = Math.Max(prefSize.Width, anchorInfo is null ? bounds.Right : bounds.Right + anchorInfo.Right); 1154? Math.Max(prefSize.Width, elementSpace.Right + anchorDest.Width) 1155: Math.Max(prefSize.Width, anchorDest.Right); 1168prefSize.Height = Math.Max(prefSize.Height, anchorInfo is null ? bounds.Bottom : bounds.Bottom + anchorInfo.Bottom); 1173? Math.Max(prefSize.Height, elementSpace.Bottom + anchorDest.Height) 1174: Math.Max(prefSize.Height, anchorDest.Bottom);
System\Windows\Forms\Layout\FlowLayout.cs (2)
93layoutSize.Width = Math.Max(layoutSize.Width, rowSize.Width); 253rowSize.Height = Math.Max(rowSize.Height, requiredSize.Height);
System\Windows\Forms\Layout\LayoutUtils.cs (12)
51largestSize.Width = Math.Max(largestSize.Width, textSize.Width); 52largestSize.Height = Math.Max(largestSize.Height, textSize.Height); 145padding.Left = Math.Max(0, padding.Left); 146padding.Top = Math.Max(0, padding.Top); 147padding.Right = Math.Max(0, padding.Right); 148padding.Bottom = Math.Max(0, padding.Bottom); 208Math.Max(a.Width, b.Width), 209Math.Max(a.Height, b.Height)); 215Math.Min(a.Width, b.Width), 216Math.Min(a.Height, b.Height)); 399currentSize.Width = Math.Max(currentSize.Width, contentSize.Width); 405currentSize.Height = Math.Max(currentSize.Height, contentSize.Height);
System\Windows\Forms\Layout\TableLayout.ContainerInfo.cs (2)
261_minColumns = Math.Max(_minColumns, layoutInfo.ColumnPosition + layoutInfo.ColumnSpan); 262_minRows = Math.Max(_minRows, layoutInfo.RowPosition + layoutInfo.RowSpan);
System\Windows\Forms\Layout\TableLayout.cs (43)
108containerSize.Width = Math.Max(containerSize.Width, 1); 109containerSize.Height = Math.Max(containerSize.Height, 1); 165containerSize.Width = Math.Max(containerSize.Width, 1); 166containerSize.Height = Math.Max(containerSize.Height, 1); 168containerInfo.ColumnStyles[0].SetSize(Math.Max(oldWidth, Math.Min(proposedConstraints.Width, containerSize.Width))); 178proposedConstraints.Width = Math.Max(proposedConstraints.Width, 1); 179proposedConstraints.Height = Math.Max(proposedConstraints.Height, 1); 267numRows = Math.Max(1, numRows); 268numCols = Math.Max(1, numCols); 289int estimatedCols = Math.Max((int)Math.Ceiling((float)minSpace / numRows), minColumn); 292estimatedCols = Math.Max(estimatedCols, 1); 306xAssignRowsAndColumns(containerInfo, childrenInfo, maxColumns: Math.Max(minColumn, 1), maxRows: int.MaxValue, growStyle); 371rowStop = Math.Min(currentRow + flowElement.RowSpan, maxRows); 391fixedElement!.RowStart = Math.Min(fixedElement.RowPosition, maxRows - 1); 392fixedElement.ColumnStart = Math.Min(fixedElement.ColumnPosition, maxColumns - 1); 401fixedElement.ColumnStart = Math.Max(fixedElement.ColumnStart, currentCol); 408fixedElement.RowStart = Math.Max(fixedElement.RowStart, currentRow); 436colStop = Math.Min(fixedElement.ColumnStart + fixedElement.ColumnSpan, maxColumns); 437rowStop = Math.Min(fixedElement.RowStart + fixedElement.RowSpan, maxRows); 446numRows = (numRows == int.MaxValue) ? rowStop : Math.Max(numRows, rowStop); 447numColumns = (numColumns == int.MaxValue) ? colStop : Math.Max(numColumns, colStop); 463numRows = Math.Max(containerInfo.MaxRows, numRows); 468numColumns = Math.Max(containerInfo.MaxColumns, numColumns); 591colStop = Math.Min(layoutInfo.ColumnSpan, maxColumns); 646int expandLastElementWidth = Math.Max(0, proposedConstraints.Width - preferredSize.Width); 661strip.MinSize = (int)Math.Round((double)styles[i].Size); 741int colStop = Math.Min(layoutInfo.ColumnStart + layoutInfo.ColumnSpan, containerInfo.Columns.Length); 780int stealAmount = Math.Min(currentOverflow, totalPercentAllocatedSpace); 858int rowStop = Math.Min(layoutInfo.RowStart + layoutInfo.RowSpan, containerInfo.Rows.Length); 874for (int i = start; i < Math.Min(start + span, strips.Length); i++) 901desiredLength = Math.Max(0, desiredLength); 957int offset = Math.Min(sizeProxy.Size, missingLength); 1077totalPercentAllocatedSpace = Math.Max(0, maxSize - totalAbsoluteAndAutoSizeAllocatedSpace); 1133int totalWidth = (int)Math.Round(((strip.MinSize * totalPercent) / style.Size)); 1134maxPercentWidth = Math.Max(maxPercentWidth, totalWidth); 1157int delta = Math.Min(strip.MaxSize - strip.MinSize, remainingSpace); 1263cellBounds.Width = Math.Max(cellBounds.Width, 1); 1264cellBounds.Height = Math.Max(cellBounds.Height, 1); 1272elementBounds.Width = Math.Min(cellBounds.Width, elementBounds.Width); 1273elementBounds.Height = Math.Min(cellBounds.Height, elementBounds.Height); 1413minColumn = Math.Max(minColumn, layoutInfo.ColumnPosition + layoutInfo.ColumnSpan);
System\Windows\Forms\MDI\MDIClient.cs (4)
195int sx = (int)Math.Round(bounds.X * dx); 196int sy = (int)Math.Round(bounds.Y * dy); 197int sw = (int)Math.Round((bounds.X + bounds.Width) * dx - sx); 198int sh = (int)Math.Round((bounds.Y + bounds.Height) * dy - sy);
System\Windows\Forms\Panels\TableLayoutPanel\TableLayoutPanel.cs (4)
529cs.Width = (float)Math.Round(lastColumnHeight * factor.Width); 533cs.Width = (float)Math.Round(cs.Width * factor.Width); 550rs.Height = (float)Math.Round(lastRowHeight * factor.Height); 554rs.Height = (float)Math.Round(rs.Height * factor.Height);
System\Windows\Forms\Printing\PageSetupDialog.cs (4)
322dialogSettings.rtMargin.left = Math.Max(dialogSettings.rtMargin.left, dialogSettings.rtMinMargin.left); 323dialogSettings.rtMargin.top = Math.Max(dialogSettings.rtMargin.top, dialogSettings.rtMinMargin.top); 324dialogSettings.rtMargin.right = Math.Max(dialogSettings.rtMargin.right, dialogSettings.rtMinMargin.right); 325dialogSettings.rtMargin.bottom = Math.Max(dialogSettings.rtMargin.bottom, dialogSettings.rtMinMargin.bottom);
System\Windows\Forms\Printing\PrintPreviewControl.cs (11)
211value = Math.Min(value, _pageInfo.Length - (_rows * _columns)); 214value = Math.Max(value, 0); 430rect.Width = Math.Max(0, rect.Width - 1); 431rect.Height = Math.Max(0, rect.Height - 1); 488_zoom = Math.Min(zoomX, zoomY); 626Math.Max(0, (rect.Width - _virtualSize.Width) / 2), 627Math.Max(0, (rect.Height - _virtualSize.Height) / 2)); 658_zoom = Math.Min(zoomX, zoomY); 670maxImageHeight = Math.Max(maxImageHeight, imagePixels.Height); 764_hScrollBar.Value = Math.Clamp(value.X, _hScrollBar.Minimum, _hScrollBar.Maximum); 765_vScrollBar.Value = Math.Clamp(value.Y, _vScrollBar.Minimum, _vScrollBar.Maximum);
System\Windows\Forms\Rendering\ControlPaint.cs (3)
1900int minDim = Math.Min(width, height); 1920int size = Math.Min(width, height); 2420if (Math.Abs(pixelColorWrapper.Luminosity - backgroundColorWrapper.Luminosity) > MaximumLuminosityDifference)
System\Windows\Forms\Rendering\ControlPaint.HLSColor.cs (4)
38int max = Math.Max(Math.Max(r, g), b); 39int min = Math.Min(Math.Min(r, g), b);
System\Windows\Forms\Rendering\FontCache.Data.cs (1)
83int pixelsY = (int)Math.Ceiling(ScaleHelper.InitialSystemDpi * font.SizeInPoints / 72);
System\Windows\Forms\Rendering\TextExtensions.cs (4)
119leftMargin = (int)Math.Ceiling(overhangPadding); 120rightMargin = (int)Math.Ceiling(overhangPadding * (1 + ItalicPaddingFactor)); 126leftMargin = (int)Math.Ceiling(2 * overhangPadding); 127rightMargin = (int)Math.Ceiling(overhangPadding * (2 + ItalicPaddingFactor));
System\Windows\Forms\Scrolling\ScrollableControl.cs (8)
223displayRectangle.Width = Math.Max(displayRectangle.Width, AutoScrollMinSize.Width); 224displayRectangle.Height = Math.Max(displayRectangle.Height, AutoScrollMinSize.Height); 620pos = Math.Max(pos - e.Delta, 0); 621pos = Math.Min(pos, maxPos); 636pos = Math.Max(pos - e.Delta, 0); 637pos = Math.Min(pos, maxPos); 755int minX = Math.Min(client.Width - displayRectangle.Width, 0); 756int minY = Math.Min(client.Height - displayRectangle.Height, 0);
System\Windows\Forms\Scrolling\ScrollBar.cs (7)
216return Math.Min(_largeChange, _maximum - _minimum + 1); 304return Math.Min(_smallChange, LargeChange); 541while (Math.Abs(_wheelDelta) >= PInvoke.WHEEL_DELTA) 683newValue = Math.Max(_value - SmallChange, _minimum); 687newValue = Math.Min(_value + SmallChange, _maximum - LargeChange + 1); 691newValue = Math.Max(_value - LargeChange, _minimum); 695newValue = Math.Min(_value + LargeChange, _maximum - LargeChange + 1);
System\Windows\Forms\Scrolling\ScrollProperties.cs (2)
81return Math.Min(_largeChange, _maximum - _minimum + 1); 191return Math.Min(_smallChange, LargeChange);
System\Windows\Forms\ToolTip\ToolTip.cs (8)
1575locationWeights[i] += Math.Abs((long)intersection.Width * intersection.Height); // Intersection is a weight 1588locationClippedAreas[i] = (Math.Abs((long)possibleLocations[i].Width) - Math.Abs((long)locationAreaWithinScreen.Width)) 1589* (Math.Abs((long)possibleLocations[i].Height) - Math.Abs((long)locationAreaWithinScreen.Height)); 1603locationWithinTopControlAreas[i] = Math.Abs((long)locationWithinTopControlRectangle.Height * locationWithinTopControlRectangle.Width); 2088? Math.Min(currentTooltipSize.Width - 2 * BalloonOffsetX, screen.WorkingArea.Width) 2089: Math.Min(currentTooltipSize.Width, screen.WorkingArea.Width);
System.Windows.Forms.Design (176)
System\ComponentModel\Design\CollectionEditor.CollectionEditorCollectionForm.cs (9)
23private static readonly double s_log10 = Math.Log(10); 211int c = Math.Max(2, _listBox.Items.Count); 214int charactersInNumber = ((int)(Math.Log(c - 1) / s_log10) + 1); 217w = Math.Max(w, (int)Math.Ceiling(sizeW.Width)); 227return (int)Math.Ceiling(size.Width) + w + pic + SystemInformation.BorderSize.Width * 4; 566int charactersInNumber = ((int)(Math.Log(maxC) / s_log10) + 1); // Luckily, this is never called if count = 0 569w = Math.Max(w, (int)Math.Ceiling(sizeW.Width));
System\ComponentModel\Design\DesignerActionPanel.cs (2)
381panelWidth = Math.Max(panelWidth, size.Width); 785editXPos = Math.Max(editXPos, line.GetEditRegionXPos());
System\ComponentModel\Design\DesignerActionPanel.EditorPropertyLine.cs (11)
95maxWidth = Math.Max(textSize.Width, maxWidth); 105listBox.Height = Math.Max(tm.tmHeight + 2, Math.Min(ListBoxMaximumHeight, listBox.PreferredHeight)); 106listBox.Width = Math.Max(maxWidth, EditRegionSize.Width); 338hostedControl.Width = Math.Max(hostedControl.Width, EditRegionSize.Width - 2); 348dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); 350editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip 351Math.Max(rectScreen.X, editorLocation.X + editorBounds.Right - dropDownSize.Width)); // max = left screen edge clip 372dropDownSize.Width = Math.Max(editorBounds.Width + 1, dropDownSize.Width); 374editorLocation.X = Math.Min(rectScreen.Right - dropDownSize.Width, // min = right screen edge clip 375Math.Max(rectScreen.X, editorLocation.X - editorBounds.Width)); // max = left screen edge clip
System\ComponentModel\Design\DesignerActionPanel.EditorPropertyLine.FlyoutDialog.cs (2)
36int width = Math.Max(_hostedControl.Width, SystemInformation.MinimumWindowSize.Width); 37int height = Math.Max(_hostedControl.Height, SystemInformation.MinimizedWindowSize.Height);
System\ComponentModel\Design\DesignerActionPanel.PanelHeaderLine.cs (1)
72int newWidth = Math.Max(titleSize.Width, subtitleSize.Width) + 2 * PanelHeaderHorizontalPadding;
System\ComponentModel\Design\DesignerActionPanel.TextBoxPropertyLine.cs (2)
98int editRegionXPos = Math.Max(_editXPos, GetEditRegionXPos()); 100width = Math.Max(width, minimumWidth);
System\ComponentModel\Design\MultilineStringEditor.MultilineStringEditorUI.cs (7)
161requestedSize.Width = Math.Max(requestedSize.Width, MinimumSize.Width); 172int requestedDelta = Math.Min((requestedSize.Width - ClientSize.Width), maxDelta); 241(int)Math.Min(Math.Ceiling(WatermarkSize.Width * 1.75), workingArea.Width / 3), 242Math.Min(Font.Height * 10, workingArea.Height / 3)); 366_watermarkSize = new Size((int)Math.Ceiling(size.Width), (int)Math.Ceiling(size.Height));
System\ComponentModel\Design\SelectionService.cs (1)
262_contextKeyword = (short)Math.Min(count, s_selectionKeywords.Length - 1);
System\ComponentModel\Design\Serialization\CodeDomSerializerBase.cs (1)
1329int maxIndex = Math.Max(leftTypeIndex, rightTypeIndex);
System\Drawing\Design\CursorEditor.CursorUI.cs (1)
23ItemHeight = Math.Max(4 + Cursors.Default.Size.Height, Font.Height);
System\Windows\Forms\Design\Behavior\ContainerSelectorBehavior.cs (2)
177Size delta = new(Math.Abs(mouseLoc.X - InitialDragPoint.X), Math.Abs(mouseLoc.Y - InitialDragPoint.Y));
System\Windows\Forms\Design\Behavior\DragAssistanceManager.cs (22)
296if (Math.Abs(delta) < Math.Abs(smallestDelta)) 313if ((Math.Abs(smallestDelta) < Math.Abs(smallestDistance)) || 314((Math.Abs(smallestDelta) == Math.Abs(smallestDistance)) && (pri > highestPriority))) 798if (Math.Abs(distances[i]) < distanceValue) 800distanceValue = Math.Abs(distances[i]); 827int coord = Math.Max(dragRect.Top, lines[i].OriginalBounds.Top); 828coord += (Math.Min(dragRect.Bottom, lines[i].OriginalBounds.Bottom) - coord) / 2; 832lines[i].X1 = Math.Min(dragRect.Right, lines[i].OriginalBounds.Right); 833lines[i].X2 = Math.Max(dragRect.Left, lines[i].OriginalBounds.Left); 851int coord = Math.Max(dragRect.Left, lines[i].OriginalBounds.Left); 852coord += (Math.Min(dragRect.Right, lines[i].OriginalBounds.Right) - coord) / 2; 856lines[i].Y1 = Math.Min(dragRect.Bottom, lines[i].OriginalBounds.Bottom); 857lines[i].Y2 = Math.Max(dragRect.Top, lines[i].OriginalBounds.Top); 944line = new Line(snapLine.Offset, Math.Min(dragBounds.Top + (_snapPointY != INVALID_VALUE ? _snapPointY : 0), bounds.Top), 945snapLine.Offset, Math.Max(dragBounds.Bottom + (_snapPointY != INVALID_VALUE ? _snapPointY : 0), bounds.Bottom)) 954line = new Line(Math.Min(dragBounds.Left + (_snapPointX != INVALID_VALUE ? _snapPointX : 0), bounds.Left), snapLine.Offset, 955Math.Max(dragBounds.Right + (_snapPointX != INVALID_VALUE ? _snapPointX : 0), bounds.Right), snapLine.Offset) 1126_snapPointX = (Math.Abs(smallestDistanceVert) <= SnapDistance) ? -smallestDistanceVert : INVALID_VALUE; 1127_snapPointY = (Math.Abs(smallestDistanceHorz) <= SnapDistance) ? -smallestDistanceHorz : INVALID_VALUE;
System\Windows\Forms\Design\Behavior\DragAssistanceManager.Line.cs (12)
53new(l1.X1, Math.Min(l1.Y1, l2.Y1), l1.X1, Math.Max(l1.Y1, l2.Y1)), 54new(l1.X1, Math.Min(l1.Y2, l2.Y2), l1.X1, Math.Max(l1.Y2, l2.Y2)) 62new(Math.Min(l1.X1, l2.X1), l1.Y1, Math.Max(l1.X1, l2.X1), l1.Y1), 63new(Math.Min(l1.X2, l2.X2), l1.Y1, Math.Max(l1.X2, l2.X2), l1.Y1) 87return new Line(l1.X1, Math.Min(l1.Y1, l2.Y1), l1.X2, Math.Max(l1.Y2, l2.Y2), l1.LineType); 93return new Line(Math.Min(l1.X1, l2.X1), l1.Y1, Math.Max(l1.X2, l2.X2), l1.Y2, l1.LineType);
System\Windows\Forms\Design\Behavior\ResizeBehavior.cs (13)
149rect.Width = Math.Max(rect.Width, _parentGridSize.Width); 150rect.Height = Math.Max(rect.Height, _parentGridSize.Height); 442return pixelsMoved - (integralHeight - (Math.Abs(pixelsMoved) % integralHeight)); 492if (Math.Abs(_initialPoint.X - mouseLoc.X) > DesignerUtils.MinDragSize.Width / 2 || Math.Abs(_initialPoint.Y - mouseLoc.Y) > DesignerUtils.MinDragSize.Height / 2) 549int minHeight = Math.Max(targetControl.MinimumSize.Height, MINSIZE); 550int minWidth = Math.Max(targetControl.MinimumSize.Width, MINSIZE); 679bounds.Height = Math.Max(minHeight, baseBounds.Height + pixelHeight); 697bounds.Height = Math.Max(minHeight, baseBounds.Height + yOffset); 704bounds.Y = Math.Min(baseBounds.Bottom - minHeight, baseBounds.Y - yOffset); 718bounds.Width = Math.Max(minWidth, baseBounds.Width + (!fRTL ? (mouseLoc.X - xOffset) : (xOffset - mouseLoc.X))); 732bounds.Width = Math.Max(minWidth, baseBounds.Width + xOffset); 739bounds.X = Math.Min(baseBounds.Right - minWidth, baseBounds.X - xOffset);
System\Windows\Forms\Design\Behavior\TableLayoutPanelBehavior.cs (3)
293newRightSize = Math.Max(rightStyleSize - delta, DesignerUtils.s_minimumSizeDrag); 301newLeftSize = Math.Max(leftStyleSize + delta, DesignerUtils.s_minimumSizeDrag); 344newAbsSize = Math.Max(absIndex == rightIndex ? curAbsStyleSize - delta : curAbsStyleSize + delta,
System\Windows\Forms\Design\Behavior\ToolboxItemSnapLineBehavior.cs (2)
168if (Math.Max(line.Y1, line.Y2) <= _lastRectangle.Top) 186if (Math.Max(line.X1, line.X2) <= _lastRectangle.Left)
System\Windows\Forms\Design\CommandSet.cs (3)
1724int shortIndex = Math.Max(0, shorterList.Count - 1); 1725int longIndex = Math.Max(0, longerList.Count - 1); 2766int lastIndex = Math.Max(0, n - 1);
System\Windows\Forms\Design\ComponentTray.cs (16)
1205_mouseDragWorkspace.X = Math.Min(start.X, end.X); 1206_mouseDragWorkspace.Y = Math.Min(start.Y, end.Y); 1207_mouseDragWorkspace.Width = Math.Abs(end.X - start.X); 1208_mouseDragWorkspace.Height = Math.Abs(end.Y - start.Y); 1340X = Math.Min(_mouseDragStart.X, e.X), 1341Y = Math.Min(_mouseDragStart.Y, e.Y), 1342Width = Math.Abs(e.X - _mouseDragStart.X), 1343Height = Math.Abs(e.Y - _mouseDragStart.Y) 1996rc.Width = Math.Max(_cxIcon, sz.Width) + 4 * _borderWidth + 2 * WhiteSpace; 2002rc.Height = Math.Max(_cyIcon, sz.Height) + 4 * _borderWidth; 2191minDrag.Width = Math.Max(minDrag.Width, minDblClick.Width); 2192minDrag.Height = Math.Max(minDrag.Height, minDblClick.Height); 2196(Math.Abs(_mouseDragLast.X - newPt.X) < minDrag.Width && 2197Math.Abs(_mouseDragLast.Y - newPt.Y) < minDrag.Height)) 2422if (Math.Abs(bounds.X - x) > parentGridSize.Width || Math.Abs(bounds.Y - y) > parentGridSize.Height)
System\Windows\Forms\Design\ControlDesigner.cs (6)
301return new Point(Math.Abs(nativeOffset.X - offset.X), nativeOffset.Y - offset.Y); 1380minDrag.Width = Math.Max(minDrag.Width, minDblClick.Width); 1381minDrag.Height = Math.Max(minDrag.Height, minDblClick.Height); 1385(Math.Abs(_mouseDragLast.X - x) < minDrag.Width && 1386Math.Abs(_mouseDragLast.Y - y) < minDrag.Height)) 2260Math.Max(SystemInformation.ToolWindowCaptionHeight - SystemInformation.BorderSize.Height - 2, Control.Font.Height),
System\Windows\Forms\Design\DataGridViewColumnCollectionDialog.cs (4)
805_selectedColumns.SelectedIndex = Math.Min(0, _selectedColumns.Items.Count - 1); 834_selectedColumns.SelectedIndex = Math.Min(_selectedColumns.Items.Count - 1, selectedIndex); 881_selectedColumns.SelectedIndex = Math.Min(selectedIndex, _selectedColumns.Items.Count - 1); 1161maxItemWidth = Math.Max(maxItemWidth, itemWidth);
System\Windows\Forms\Design\DataGridViewColumnDesigner.cs (1)
131value = Math.Max(col.MinimumWidth, value);
System\Windows\Forms\Design\DataGridViewColumnTypeEditor.Picker.cs (4)
50width = Math.Max(width, Size.Ceiling(g.MeasureString(item.ToString(), _typesListBox.Font)).Width); 63width = Math.Max(width, MinimumWidth); 68height = Math.Max(height, MinimumHeight); 116Width = Math.Max(Width, PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2));
System\Windows\Forms\Design\DesignBindingPicker.cs (5)
578Width = Math.Max(Width, _treeViewCtrl is null ? 0 : _treeViewCtrl.PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2)); 1669width = Math.Max(width, s_minimumWidth); 1674height = Math.Max(height, s_minimumHeight); 2032maxWidth = Math.Max(w, maxWidth); 2035maxWidth = Math.Max(maxWidth, GetMaxItemWidth(node.Nodes));
System\Windows\Forms\Design\DesignerUtils.cs (6)
146s_minDragSize.Width = Math.Max(minDrag.Width, minDblClick.Width); 147s_minDragSize.Height = Math.Max(minDrag.Height, minDblClick.Height); 390Math.Max(control.Width, s_minimumControlBitmapSize), 391Math.Max(control.Height, s_minimumControlBitmapSize), 423Math.Max(control.Width, s_minimumControlBitmapSize), 424Math.Max(control.Height, s_minimumControlBitmapSize),
System\Windows\Forms\Design\DockEditor.DockUI.cs (4)
236? _leftRightOrder[Math.Max(i - 1, 0)] 237: _leftRightOrder[Math.Min(i + 1, maxI)]; 278? _upDownOrder[Math.Max(i - 1, 0)] 279: _upDownOrder[Math.Min(i + 1, maxI)];
System\Windows\Forms\Design\FlowLayoutPanelDesigner .cs (3)
69private readonly int _maxIBarWidth = Math.Max(IBarHalfSize, (IBarHatWidth - 1) / 2); 484if (Math.Abs(point1.Y - point2.Y) <= MinIBar) 523if (Math.Abs(point1.X - point2.X) <= MinIBar)
System\Windows\Forms\Design\FormatControl.cs (4)
377minWidth = Math.Max(minWidth, secondRowLabel.Width); 378minHeight = Math.Max(minHeight, secondRowLabel.Height); 381minWidth = Math.Max(minWidth, secondRowLabel.Width); 382minHeight = Math.Max(minHeight, secondRowLabel.Height);
System\Windows\Forms\Design\FormDocumentDesigner.cs (4)
66return new Size((int)Math.Round(real.Width), (int)Math.Round(real.Height)); 269Size newVar = new((int)Math.Round(newVarF.Width), (int)Math.Round(newVarF.Height));
System\Windows\Forms\Design\ParentControlDesigner.cs (4)
2032Rectangle paintRect = new(Math.Min(displayRect.X, clientRect.X), 2033Math.Min(displayRect.Y, clientRect.Y), 2034Math.Max(displayRect.Width, clientRect.Width), 2035Math.Max(displayRect.Height, clientRect.Height));
System\Windows\Forms\Design\SelectionUIHandler.cs (2)
484Size size = new(Math.Max(MinControlWidth, newBounds.Width), Math.Max(MinControlHeight, newBounds.Height));
System\Windows\Forms\Design\SelectionUIService.cs (2)
631Math.Abs(screenCoord.X - _mouseDragAnchor.X) < minDragSize.Width && 632Math.Abs(screenCoord.Y - _mouseDragAnchor.Y) < minDragSize.Height)
System\Windows\Forms\Design\TableLayoutPanelDesigner.cs (6)
1202_rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative 1203_colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length); 1237bool fullTable = (totalArea - 1) >= (Math.Max(1, _colCountBeforeAdd) * Math.Max(1, _rowCountBeforeAdd)); 1342_rowCountBeforeAdd = Math.Max(0, Table.GetRowHeights().Length); // don't want negative 1343_colCountBeforeAdd = Math.Max(0, Table.GetColumnWidths().Length);
System\Windows\Forms\Design\ToolStripDesigner.cs (2)
1057itemIndex = Math.Min(ToolStrip.Items.Count - 1, itemIndex); 1058itemIndex = Math.Max(0, itemIndex);
System\Windows\Forms\Design\ToolStripDesignerUtils.cs (1)
547s_bitsPerPixel = (short)Math.Min(s.BitsPerPixel, s_bitsPerPixel);
System\Windows\Forms\Design\ToolStripItemBehavior.cs (2)
405int startIndexOfSelection = Math.Min(parent.Items.IndexOf(selectedItem), parent.Items.IndexOf(glyphItem)); 406int endIndexOfSelection = Math.Max(parent.Items.IndexOf(selectedItem), parent.Items.IndexOf(glyphItem));
System\Windows\Forms\Design\ToolStripKeyboardHandlingService.cs (2)
691int endIndexOfSelection = Math.Max(0, parent.Items.IndexOf(item)); 736int endIndexOfSelection = Math.Max(startIndexOfSelection, count - 2);
System\Windows\Forms\Design\ToolStripMenuItemDesigner.cs (4)
1909itemIndex = Math.Min(ownerItem.DropDownItems.Count - 1, itemIndex); 1910itemIndex = Math.Max(0, itemIndex); 2537int maxIndex = Math.Max(ownerDropDown.Items.IndexOf(oldSelection), ownerDropDown.Items.IndexOf(MenuItem)); 2538int minIndex = Math.Min(ownerDropDown.Items.IndexOf(oldSelection), ownerDropDown.Items.IndexOf(MenuItem));
System.Windows.Forms.Primitives (20)
System\Windows\Forms\Automation\UiaTextRange.cs (13)
193End = Math.Min(Math.Max(End, Start + 1), text.Length); 245End = Math.Min(Math.Max(End, Start + 1), text.Length); 362Rectangle endlineRectangle = new(endlinePoint.X, endlinePoint.Y + 2, UiaTextProvider.EndOfLineWidth, Math.Abs(_provider.Logfont.lfHeight) + 1); 436maxLength = maxLength >= 0 ? Math.Min(Length, maxLength) : Length; 595: Math.Max(0, _provider.GetLineFromCharIndex(End) - _provider.LinesPerPage + 1); 743int lineHeight = Math.Abs(_provider.Logfont.lfHeight); 887return Math.Round((double)(-logfont.lfHeight) * 72 / lpy); 934moved = Math.Min(count, limit - index); 973moved = Math.Min(count, lineMax - line - 1); 1049moved = Math.Max(count, -oneBasedIndex); 1084int actualCount = Math.Max(count, -line);
System\Windows\Forms\Internals\ScaleHelper.cs (4)
242textScale = Math.Clamp(textScale, MinTextScaleValue, MaxTextScaleValue); 261internal static int ScaleToPercent(int value, double percent) => Math.Max(1, (int)Math.Round(value * percent)); 276return (int)Math.Round(scalingFactor * logicalValue);
System\Windows\Forms\Internals\UnicodeCharBuffer.cs (1)
51int count = Math.Min(s.Length, _buffer.Length - _offset);
Windows\Win32\PInvoke.GetModuleFileNameLongPath.cs (1)
41buffer.EnsureCapacity(Math.Min(buffer.Length * 2, short.MaxValue));
Windows\Win32\Pinvoke.RegLoadMUIString.cs (1)
39? buffer[..Math.Max((int)(bytes / sizeof(char)) - 1, 0)].ToString()
System.Windows.Forms.Primitives.TestUtilities (2)
GdiHelper.cs (2)
39=> (int)Math.Round((double)((long)LogicalPixelsX * himetric) / HiMetricPerInch, 0); 45=> (int)Math.Round((double)((long)LogicalPixelsY * himetric) / HiMetricPerInch, 0);
System.Windows.Forms.Tests (6)
DpiHelperTests.cs (3)
15int expected = (int)Math.Round(value * (ScaleHelper.InitialSystemDpi / (double)ScaleHelper.OneHundredPercentLogicalDpi)); 25(int)Math.Round(value.Width * (ScaleHelper.InitialSystemDpi / (double)ScaleHelper.OneHundredPercentLogicalDpi)), 26(int)Math.Round(value.Height * (ScaleHelper.InitialSystemDpi / (double)ScaleHelper.OneHundredPercentLogicalDpi)));
System\Windows\Forms\AccessibleObjects\ComboBox.ComboBoxItemAccessibleObjectTests.cs (1)
320int visibleItemsCount = (int)Math.Ceiling((double)dropDownRect.Height / comboBox.ItemHeight);
System\Windows\Forms\ToolStripDropDownTests.cs (2)
1931expected.X = Math.Max(expected.X, SystemInformation.WorkingArea.X); 1932expected.Y = Math.Max(expected.Y, SystemInformation.WorkingArea.Y);
System.Windows.Forms.UI.IntegrationTests (14)
ButtonTests.cs (6)
263Point virtualPoint = new((int)Math.Round(65535.0 / horizontalResolution * centerOnScreen.X), 264(int)Math.Round(65535.0 / verticalResolution * centerOnScreen.Y)); 299Point virtualPoint = new((int)Math.Round(65535.0 / horizontalResolution * centerOnScreen.X), (int)Math.Round(65535.0 / verticalResolution * centerOnScreen.Y)); 300Point virtualPoint1 = new((int)Math.Round(65535.0 / horizontalResolution * centerOnScreen1.X), (int)Math.Round(65535.0 / verticalResolution * centerOnScreen1.Y));
Dpi\DpiMessageHelper.cs (2)
25(int)Math.Round(control.Width * factor), 26(int)Math.Round(control.Height * factor));
Infra\ControlTestBase.cs (2)
185(int)Math.Ceiling((65535.0 / (primaryMonitor.Width - 1)) * point.X), 186(int)Math.Ceiling((65535.0 / (primaryMonitor.Height - 1)) * point.Y));
Infra\DataCollectionService.cs (1)
221testName = testName[..Math.Max(0, testName.Length - (path.Length - MaxPath))];
Infra\ScreenRecordService.cs (3)
296lastChangedColumn = Math.Max(lastChangedColumn, column); 547for (ReadOnlySpan<byte> remaining = bytes; !remaining.IsEmpty; remaining = remaining[Math.Min(buffer.Length, remaining.Length)..]) 549ReadOnlySpan<byte> current = remaining[..Math.Min(buffer.Length, remaining.Length)];
System.Windows.Input.Manipulations (34)
System\Windows\Input\Manipulations\DoubleUtil.cs (1)
158return Math.Abs(d) <= DBL_EPSILON;
System\Windows\Input\Manipulations\InertiaProcessor2D.cs (9)
618initialTranslationX.AbsoluteOffset = Math.Abs(desiredTranslationXY.X); 619initialTranslationY.AbsoluteOffset = Math.Abs(desiredTranslationXY.Y); 629initialTranslationX.AbsoluteDeceleration = Math.Abs(desiredDecelerationXY.X); 630initialTranslationY.AbsoluteDeceleration = Math.Abs(desiredDecelerationXY.Y); 697state.Duration = 2 * Math.Abs(state.Offset / state.InitialVelocity); 706state.AbsoluteDeceleration = Math.Abs(state.InitialVelocity) / state.Duration; 723state.Duration = Math.Abs(state.InitialVelocity) / state.AbsoluteDeceleration; 1081result = new VectorD(Math.Abs(baseVector.X * scale), 1082Math.Abs(baseVector.Y * scale));
System\Windows\Input\Manipulations\ManipulationSequence.cs (16)
900double oldAngle = Math.Atan2(oldVectorForRotationCalc.Y, oldVectorForRotationCalc.X); 901double newAngle = Math.Atan2(newVectorForRotationCalc.Y, newVectorForRotationCalc.X); 903if (delta > Math.PI) 904delta -= Math.PI * 2.0; 905if (delta < -Math.PI) 906delta += Math.PI * 2.0; 959torqueFactor = (float)Math.Min(1.0, Math.Pow(oldVector.Length / settings.Pivot.Radius, singleManipulatorTorqueFactor)); 1170float value2 = value + (float)(2 * Math.PI); 1171float value3 = value - (float)(2 * Math.PI); 1172float delta = Math.Abs(baseValue - value); 1173if (Math.Abs(baseValue - value2) < delta) 1177else if (Math.Abs(baseValue - value3) < delta) 1344smoothingLevel = Math.Max(0, Math.Min(1, smoothingLevel)); 1347int newHistoryLength = (int)Math.Round(smoothingLevel * MaxHistoryLength);
System\Windows\Input\Manipulations\VectorD.cs (1)
361return Math.Sqrt(LengthSquared);
System\Windows\Input\Manipulations\VectorF.cs (7)
346return (float)Math.Sqrt(LengthSquared); 411double angle = Math.Atan2(vector2.y, vector2.x) - Math.Atan2(vector1.y, vector1.x); 412if (angle > Math.PI) 414angle -= Math.PI * 2.0; 416else if (angle < -Math.PI) 418angle += Math.PI * 2.0;
System.Xaml (1)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Utility\FrugalList.cs (1)
1523int newCapacity = Math.Max(newCount + (newCount >> 2), MINSIZE);
UIAutomationClientSideProviders (27)
MS\Internal\AutomationProxies\WindowsEditBox.cs (4)
365clientLocation.x = Math.Max(clientLocation.x, clientRect.left); 366clientLocation.x = Math.Min(clientLocation.x, clientRect.right); 367clientLocation.y = Math.Max(clientLocation.y, clientRect.top); 368clientLocation.y = Math.Min(clientLocation.y, clientRect.bottom);
MS\Internal\AutomationProxies\WindowsEditBoxRange.cs (13)
131End = Math.Min(Math.Max(End, Start + 1), text.Length); 165End = Math.Min(Math.Max(End, Start + 1), text.Length); 299return text.Substring(Start, maxLength >= 0 ? Math.Min(Length, maxLength) : Length); 473Math.Max(0, _provider.LineFromChar(End) - _provider.LinesPerPage() + 1); 658int height = Math.Abs(_provider.GetLogfont().lfHeight);; 685ArrayList rects = new ArrayList(Math.Max(endLine - startLine + 1, 0)); 780return Math.Round((double)(-logfont.lfHeight) * 72 / lpy); 827moved = Math.Min(count, limit - index); 872moved = Math.Min(count, lineMax - line - 1); 940moved = Math.Max(count, -oneBasedIndex); 985int actualCount = Math.Max(count, -line);
MS\Internal\AutomationProxies\WindowsListView.cs (2)
1047int rowCount = (int) System.Math.Ceiling (((double) itemCount) / columnCount); 1694int future = (int) Math.Round (((si.nMax - deltaPage) - si.nMin) * fScrollPos / 100.0 + si.nMin);
MS\Internal\AutomationProxies\WindowsListViewItem.cs (1)
950clickPoint.x = Math.Min ((itemRectangle.left + 5), (itemRectangle.left + itemRectangle.right) / 2);
MS\Internal\AutomationProxies\WindowsMenu.cs (1)
2321cMoves = Math.Abs (cMoves);
MS\Internal\AutomationProxies\WindowsRichEditRange.cs (4)
81_range.SetRange(Math.Max(charRange.Start, paraRange.Start), Math.Min(charRange.End, paraRange.End)); 164int start = Math.Max(_range.Start, visibleRange.Start); 165int end = Math.Min(_range.End, visibleRange.End);
MS\Internal\AutomationProxies\WindowsScroll.cs (1)
303int newPos = (int) Math.Round (((si.nMax - delta) - si.nMin) * fScrollPos / 100.0 + si.nMin);
MS\Internal\AutomationProxies\WindowsTab.cs (1)
516int newPos = (int) Math.Round ((maxPos - minPos) * horizontalPercent / 100) + minPos;
UIAutomationTypes (3)
src\Microsoft.DotNet.Wpf\src\Shared\MS\Win32\HandleCollector.cs (1)
170handleCount = Math.Max(0, handleCount);
src\Microsoft.DotNet.Wpf\src\Shared\MS\Win32\NativeMethodsCLR.cs (2)
2370int count = Math.Min(bytes.Length, buffer.Length - offset); 2426int count = Math.Min(s.Length, buffer.Length - offset);
VBCSCompiler (1)
src\Compilers\Server\VBCSCompiler\NamedPipeClientConnectionHost.cs (1)
69var listenCount = Math.Min(4, Environment.ProcessorCount);
WindowsFormsIntegration (13)
System\Windows\Integration\ElementHost.cs (2)
317int maxWidth = Math.Min(priorMaxSize.Width, maxElementSize.Width); 318int maxHeight = Math.Min(priorMaxSize.Height, maxElementSize.Height);
System\Windows\Integration\HostUtils.cs (7)
73Math.Max(size1.Width, size2.Width), 74Math.Max(size1.Height, size2.Height)); 80Math.Min(size1.Width, size2.Width), 81Math.Min(size1.Height, size2.Height)); 267(int)Math.Ceiling(element.ActualWidth), 268(int)Math.Ceiling(element.ActualHeight), 393return Math.Abs(value) < 10d * DBL_EPSILON;
System\Windows\Integration\WindowsFormsHost.cs (4)
252returnSize.Width = Math.Min(returnSize.Width, constraint.Width); 253returnSize.Height = Math.Min(returnSize.Height, constraint.Height); 287returnSize.Width = Math.Min(returnSize.Width, finalSize.Width); 288returnSize.Height = Math.Min(returnSize.Height, finalSize.Height);
WinFormsControlsTest (10)
ChartControl.cs (2)
22double yValue = (1.0 + Math.Sin(angle / 180.0 * Math.PI)) * 10.0;
CurrentDPILabel.cs (1)
34Text = $"Current scaling is {(int)Math.Round((DeviceDpi / 96.0) * 100)}%";
MainForm.cs (1)
295(int)Math.Ceiling((overarchingFlowLayoutPanel.Controls.Count + 1) / 3.0) * (biggestButton.Height + padding * 2)
MenuStripAndCheckedListBox.cs (2)
18currentDpiLabel.Text = $"Current scaling = {(int)Math.Round((DeviceDpi / 96.0) * 100)}%"; 23currentDpiLabel.Text = $"Current scaling = {(int)Math.Round((DeviceDpi / 96.0) * 100)}%";
TrackBars.cs (4)
73trackBar1.Minimum = (int)Math.Max(numericMinimum.Value, int.MinValue); 75numericFrequency.Maximum = (int)Math.Min(numericMaximum.Value - numericMaximum.Minimum, int.MaxValue); 86trackBar1.Maximum = (int)Math.Min(numericMaximum.Value, int.MaxValue); 88numericFrequency.Maximum = (int)Math.Min(numericMaximum.Value - numericMaximum.Minimum, int.MaxValue);
xunit.assert (36)
EqualityAsserts.cs (26)
280 var typeNameIndent = Math.Max(expectedTypeName.Length, actualTypeName.Length); 346 var expectedRounded = Math.Round(expected, precision); 347 var actualRounded = Math.Round(actual, precision); 372 var expectedRounded = Math.Round(expected, precision, rounding); 373 var actualRounded = Math.Round(actual, precision, rounding); 398 if (!(object.Equals(expected, actual) || Math.Abs(expected - actual) <= tolerance)) 418 var expectedRounded = Math.Round(expected, precision); 419 var actualRounded = Math.Round(actual, precision); 444 var expectedRounded = Math.Round(expected, precision, rounding); 445 var actualRounded = Math.Round(actual, precision, rounding); 470 if (!(object.Equals(expected, actual) || Math.Abs(expected - actual) <= tolerance)) 490 var expectedRounded = Math.Round(expected, precision); 491 var actualRounded = Math.Round(actual, precision); 794 var typeNameIndent = Math.Max(expectedTypeName.Length, actualTypeName.Length); 827 var expectedRounded = Math.Round(expected, precision); 828 var actualRounded = Math.Round(actual, precision); 853 var expectedRounded = Math.Round(expected, precision, rounding); 854 var actualRounded = Math.Round(actual, precision, rounding); 879 if (object.Equals(expected, actual) || Math.Abs(expected - actual) <= tolerance) 899 var expectedRounded = Math.Round(expected, precision); 900 var actualRounded = Math.Round(actual, precision); 925 var expectedRounded = Math.Round(expected, precision, rounding); 926 var actualRounded = Math.Round(actual, precision, rounding); 951 if (object.Equals(expected, actual) || Math.Abs(expected - actual) <= tolerance) 971 var expectedRounded = Math.Round(expected, precision); 972 var actualRounded = Math.Round(actual, precision);
Sdk\AssertHelper.cs (3)
215 var start = Math.Max(index - 20, 0); 216 var end = Math.Min(start + 41, value.Length); 217 start = Math.Max(end - 41, 0);
Sdk\CollectionTracker.cs (7)
592 var startIndex = Math.Max(0, (mismatchedIndex ?? 0) - MAX_ENUMERABLE_LENGTH_HALF); 593 var endIndex = Math.Min(span.Length - 1, startIndex + ArgumentFormatter.MAX_ENUMERABLE_LENGTH - 1); 594 startIndex = Math.Max(0, endIndex - ArgumentFormatter.MAX_ENUMERABLE_LENGTH + 1); 734 var printLength = Math.Min(currentIndex + 1, ArgumentFormatter.MAX_ENUMERABLE_LENGTH); 777 startIndex = Math.Max(0, (mismatchedIndex ?? 0) - MAX_ENUMERABLE_LENGTH_HALF); 786 startIndex = Math.Max(0, endIndex - ArgumentFormatter.MAX_ENUMERABLE_LENGTH + 1); 848 var itemIndex = Math.Max(0, CurrentIndex - ArgumentFormatter.MAX_ENUMERABLE_LENGTH + 1);