decimal

Looking for decimal to alphanumeric number base converter library in Visual Basic (or pseudo code algorithm) WITHOUT recursion

爷,独闯天下 提交于 2019-12-14 03:25:31
问题 I'm looking for a decimal to alphanumeric number base converter library in Visual Basic that does not use recursion. I found: http://visualstudiomagazine.com/articles/2010/07/20/when-hexadecimal-is-not-enough.aspx which includes a demo app but discovered that it uses recursion. The problem with it using recursion became apparent when I attempted to integrate the library into my own Visual Studio Express 2010 Visual Basic project: I got a stack overflow exception. Now I could consider

Send decimal number with commas working on c sharp mvc

非 Y 不嫁゛ 提交于 2019-12-14 02:51:26
问题 This is my first time in this very interesting forum. I'm working on a mvc project. I have my model and inside it one decimal property for currency. Also I have its edit view in which I use Html Helper TextEditorFor. This Html Helper shows at the webpage one value from de Database but it shows it as a decimal with comma. Then, When I want to send again this edit without edditing nothing, it doesn't send anything to the Database and shows the wrong TextEditBox in which I need to change the

Decimal to Unicode Char in C++

痞子三分冷 提交于 2019-12-14 02:17:50
问题 How do I convert a decimal number, 225 for example, to its corresponding Unicode character when it's being output? I can convert ASCII characters from decimal to the character like this: int a = 97; char b = a; cout << b << endl; And it output the letter "a", but it just outputs a question mark when I use the number 225, or any non-ascii character. 回答1: To start with, it's not your C++ program which converts strings of bytes written to standard output into visible characters; it's your

Python-Converting binary to decimal

自古美人都是妖i 提交于 2019-12-14 00:12:40
问题 Im doing a colledge assignment which is have us create a python program to convert binary to decimal without using the bin() function or list(). I'm plan to have each 1's and 0's stored in a function which will be multiplied later. However, I'm not sure how am i suppose to do so 回答1: Well, you could pass the binary number as a string, and iterate over it in reverse order, multiplying each 0 or 1 by 2^n, where n is a number incremented at each loop cycle. def bin2dec(b): number = 0 counter = 0

Hex to Dec conversion with printf in sh fail for more than 16 digits

﹥>﹥吖頭↗ 提交于 2019-12-13 23:46:10
问题 I only have shell available no bash, Perl, python etc. Using printf small numbers work: root@DD-WRT:/jffs# printf "%d\n", 0x15a 346 But large numbers fail. root@DD-WRT:/jffs# printf "%d\n", 0x15abc12345afda325 sh: invalid number '0x15abc12345afda325' 0 Also is it possible to perform hexadecimal arithmetic for example Module using shell ? 回答1: What shell is this? On Linux I see: $ bash -c 'echo $((0x15abc12345afda325))' 6538120775109288741 wrong $ dash -c 'echo $((0x15abc12345afda325))'

Char as a decimal separator in C

你。 提交于 2019-12-13 20:43:27
问题 I've written a function that extracts double from a string. Like asfas123123afaf to 123123 or afafas12312.23131asfa to 12312.23131 using the point as a decimal separator. Here is the code: double get_double(const char *str, char sep) { char str_dbl[80]; size_t i,j; char minus; double dbl; for (minus = 1, i = j = 0; i < strlen(str); ++i) { if ( (str[i] == '-' && minus) || (str[i] >= '0' && str[i] <= '9') || (str[i] == 'e' || str[i] == 'E') ) { str_dbl[j++] = str[i]; minus = 0; } } str_dbl[j] =

Determine which function to call based on length of decimal

删除回忆录丶 提交于 2019-12-13 17:12:58
问题 In C#, I have a situation where I have two possible numbers in a textbox control. The numbers can be either: a) .xxxx or b) .xx How do I write a condition that says, "If the textbox has 4 decimal places, then call this function, otherwise, if the textbox has 2 decimal places, then call this function." Seems easy, but I don't know how to evaluate the decimal places. Thanks much! 回答1: You can use Regex new Regex(@"\.\d{2}$").IsMatch(input.Value) 回答2: if(txtNumber.Text.Split(new[]{'.'})[1]

Validating and transforming decimal values in CakePHP

对着背影说爱祢 提交于 2019-12-13 14:33:09
问题 I'm developing an application with CakePHP that handles monetary values. The client wants the numbers to have a custom format like 1.275,34 , i.e. a dot as the delimiter in the integer part and a comma as the delimiter of the decimal part. I'm wondering what's the best approach to manage this, since i need to do two basic things: Validate values written in forms according to that custom format. Transform those values according to the format expected by MySQL's column data type ( decimal(18,2)

Need Arbitrary-Precision-Arithmetic in C#

时光毁灭记忆、已成空白 提交于 2019-12-13 13:41:47
问题 I'm in need of floating point calculations for C# that can correctly store up to maybe 500 digits/decimals. Is there any built-in-type for this, do I have to create it myself, any library available or what is the best way to go? Thanks 回答1: MPIR, a fork of the GMP project, has C# bindings. Personally, I've found them easier to deal with when raising problems, to the point that I no longer worry about GMP (primarily due to its tendency to exit violently when running out of memory). There are

C/C++: printf use commas instead of dots as decimal separator

眉间皱痕 提交于 2019-12-13 13:28:32
问题 I need that my program shows the output using commas as decimal separator. According to this link: http://www.java2s.com/Code/Java/Development-Class/Floatingpointwithcommasf.htm you can use in Java something like this: System.out.printf("Floating-point with commas: %,f\n", 1234567.123); Is there a flag or something that I can use to have a similar behaviour in C? Thanks in advance! 回答1: If you want, you can set current locale at the beginning of your program: #include <stdio.h> #include