¡@

Home 

c# Programming Glossary: math.floor

c# random string generator

http://stackoverflow.com/questions/1122483/c-sharp-random-string-generator

ch for int i 0 i size i ch Convert.ToChar Convert.ToInt32 Math.Floor 26 random.NextDouble 65 builder.Append ch return builder.ToString.. ch for int i 0 i size i ch Convert.ToChar Convert.ToInt32 Math.Floor 26 random.NextDouble 65 builder.Append ch return builder.ToString..

try catch performance

http://stackoverflow.com/questions/1350264/try-catch-performance

int c 0 for int i 0 i iterations i try c i 2 int Math.Floor double i c i 2 catch Exception ex throw stopwatch.Stop.. int c2 0 for int i 0 i iterations i c2 i 2 int Math.Floor double i c2 i 2 stopwatch2.Stop WriteLog String.Format Without.. of the for loops by something more complex like c i 2 int Math.Floor double i The difference is far less dramatic. With try catch..

Program to find prime numbers

http://stackoverflow.com/questions/1510124/program-to-find-prime-numbers

sieve in one long line like this Enumerable.Range 0 Math.Floor 2.52 Math.Sqrt num Math.Log num .Aggregate Enumerable.Range..

Formatting numbers with significant figures in C#

http://stackoverflow.com/questions/158172/formatting-numbers-with-significant-figures-in-c-sharp

decimal places. roundingPosition significantDigits 1 int Math.Floor Math.Log10 Math.Abs value try to use a rounding position directly..

Make a BackgroundWorker do several operations sequentially without freezing the form

http://stackoverflow.com/questions/1902384/make-a-backgroundworker-do-several-operations-sequentially-without-freezing-the

de complétion pour chaque étape int stepPourcent int Math.Floor double 100 3 Directory.GetDirectories cheminRacine branches..

Resizing an image in asp.net without losing the image quality

http://stackoverflow.com/questions/2319983/resizing-an-image-in-asp-net-without-losing-the-image-quality

maxHeight Double ratio Math.Max xRatio yRatio int nnx int Math.Floor img.Width ratio int nny int Math.Floor img.Height ratio Bitmap.. yRatio int nnx int Math.Floor img.Width ratio int nny int Math.Floor img.Height ratio Bitmap cpy new Bitmap nnx nny PixelFormat.Format32bppArgb..

Round a double to x significant figures

http://stackoverflow.com/questions/374316/round-a-double-to-x-significant-figures

d int digits if d 0 return 0 double scale Math.Pow 10 Math.Floor Math.Log10 Math.Abs d 1 return scale Math.Round d scale digits.. d int digits if d 0 return 0 double scale Math.Pow 10 Math.Floor Math.Log10 Math.Abs d 1 digits return scale Math.Truncate d..

Converting RGB to HSB Colors

http://stackoverflow.com/questions/4106363/converting-rgb-to-hsb-colors

fMin brightness brightness saturation iSextant int Math.Floor hue 60f if 300f hue hue 360f hue 60f hue 2f float Math.Floor.. hue 60f if 300f hue hue 360f hue 60f hue 2f float Math.Floor iSextant 1f 6f 2f if 0 iSextant 2 fMid hue fMax fMin fMin else..

Double precision problems on .NET

http://stackoverflow.com/questions/566958/double-precision-problems-on-net

public static double Floor double value double step return Math.Floor value step step That calculates the higher number lower than..

Engineering notation in C#?

http://stackoverflow.com/questions/808104/engineering-notation-in-c

exponent Math.Log10 Math.Abs d if Math.Abs d 1 switch int Math.Floor exponent case 0 case 1 case 2 return d.ToString case 3 case.. d 1e24 .ToString Y else if Math.Abs d 0 switch int Math.Floor exponent case 1 case 2 case 3 return d 1e3 .ToString m case..

How to find the actual printable area? (PrintDocument)

http://stackoverflow.com/questions/8761633/how-to-find-the-actual-printable-area-printdocument

we rotate in software for landscape int availableWidth int Math.Floor printDocument.OriginAtMargins marginBounds.Width e.PageSettings.Landscape.. printableArea.Width int availableHeight int Math.Floor printDocument.OriginAtMargins marginBounds.Height e.PageSettings.Landscape.. document is configured for landscape or portrait. I used Math.Floor for the easy way out to just drop anything past the decimal..