getch and arrow codes

By pressing one arrow key getch will push three values into the buffer: ‘\033’ ‘[‘ ‘A’, ‘B’, ‘C’ or ‘D’ So the code will be something like this: if (getch() == ‘\033’) { // if the first value is esc getch(); // skip the [ switch(getch()) { // the real value case ‘A’: // code … Read more

How would I separate thousands with space in C#

Pass in a custom NumberFormatInfo with a custom NumberGroupSeparator property, and use the #,# format to tell it to do number groups. This example uses the invariant culture’s number format as its basis. var nfi = (NumberFormatInfo)CultureInfo.InvariantCulture.NumberFormat.Clone(); nfi.NumberGroupSeparator = ” “; string formatted = 1234897.11m.ToString(“#,0.00”, nfi); // “1 234 897.11”

How can I format a decimal bound to TextBox without angering my users?

Try to resolve that on ViewModel level. That it: public class FormattedDecimalViewModel : INotifyPropertyChanged { private readonly string _format; public FormattedDecimalViewModel() : this(“F2”) { } public FormattedDecimalViewModel(string format) { _format = format; } private string _someDecimalAsString; // String value that will be displayed on the view. // Bind this property to your control public string … Read more

Convert Scientific Notation to Float

You are looking at the default str() formatting of floating point numbers, where scientific notation is used for sufficiently small or large numbers. You don’t need to convert this, the value itself is a proper float. If you need to display this in a different format, format it explicitly: >>> print(0.00001357) 1.357e-05 >>> print(format(0.00001357, ‘f’)) … Read more

Is there a Math API for Pow(decimal, decimal)

One of the multipliyers is a rate : 1/rate^(days/365). The reason there is no decimal power function is because it would be pointless to use decimal for that calculation. Use double. Remember, the point of decimal is to ensure that you get exact arithmetic on values that can be exactly represented as short decimal numbers. … Read more

Problem parsing currency text to decimal type

How about using: decimal d = decimal.Parse(“$45.00”, NumberStyles.Currency); The MSDN documentation on Decimal.Parse states: “The s parameter is interpreted using the NumberStyles.Number style. This means that white space and thousands separators are allowed but currency symbols are not. To explicitly define the elements (such as currency symbols, thousands separators, and white space) that can be … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)