decimal

How to make a REGEX statement that will allow interpretation of EU and US decimal notations

流过昼夜 提交于 2020-01-21 19:00:12
问题 I have been working on a tough question and gotten a lot of help from programmers and developers on this site. Many thanks to those who contribute. You are invaluable. Using Javascript and HTML. I am a newbie. The current condition of my problem is this... I am attempting to develop a metric to english conversion website that takes a numeric value in a HTML textbox (no form): I want the user to have multiple ways of entering the data into the conversion tool as it will be used internationally

How to make a REGEX statement that will allow interpretation of EU and US decimal notations

狂风中的少年 提交于 2020-01-21 19:00:07
问题 I have been working on a tough question and gotten a lot of help from programmers and developers on this site. Many thanks to those who contribute. You are invaluable. Using Javascript and HTML. I am a newbie. The current condition of my problem is this... I am attempting to develop a metric to english conversion website that takes a numeric value in a HTML textbox (no form): I want the user to have multiple ways of entering the data into the conversion tool as it will be used internationally

Have decimal amount, want to trim to 2 decimal places if present

╄→尐↘猪︶ㄣ 提交于 2020-01-21 06:41:01
问题 Have decimal amount, want to trim to 2 decimal places if present 回答1: Have you tried using value = Decimal.Round(value, 2) ? For example: using System; class Test { static void Main() { decimal d = 1234.5678m; Console.WriteLine("Before: {0}", d); // Prints 1234.5678 d = decimal.Round(d, 2); Console.WriteLine("After: {0}", d); // Prints 1234.57 } } Note that this is rounding rather than just trimming (so here it's rounded up)... what exactly do you need? Chances that the Decimal struct

Mongodb PHP - Integers with decimals

ぐ巨炮叔叔 提交于 2020-01-20 08:10:18
问题 This is a follow up to another post i made about inserting an integer into mongodb. I have this working just fine by using the (int) but now when it inserts the number into the db is strips everything after the decimal. So if i had 154.65 it would be inserted into the mongodb as 154 with nothing after the decimal. My question is how do i get this to keep all numbers after the decimal? Also if anyone has a link to these sting/numeric functions i'd appreciate a reference. Thanks. $number["xyz"]

Default Number of Decimal Places to Output in PHP

无人久伴 提交于 2020-01-20 05:23:45
问题 I do my php work on my dev box at home, where I've got a rudimentary LAMP setup. When I look at my website on my home box, any numbers I echo are automatically truncated to the least required precision. Eg 2 is echoed as 2, 2.2000 is echoed as 2.2. On the production box, all the numbers are echoed with at least one unnecessary zero, eg 100 becomes 100.0. On both boxes, the PHP version is 5.2.5. Does anyone know offhand if there is a setting I can change which will force PHP to automatically

warning, "number_format() expects parameter 1 to be double, string given

风格不统一 提交于 2020-01-17 14:46:10
问题 I get this error from this line can anyone tell me who can resolve this problem. function format_numeric($str) { if(empty($str) && $str!=0) return; global $appearance_settings; $decimals = $appearance_settings['number_format_decimals']; $point = $appearance_settings['number_format_point']; $th_separator = $appearance_settings['number_format_separator']; $result = number_format($str, $decimals, $point, $th_separator); //THIS IS THE LINE WITH THE ERROR return $result; } 回答1: Judging by your

Getting non-integer results in Data Explorer

[亡魂溺海] 提交于 2020-01-17 08:05:35
问题 The Stack Exchange Data Explorer allows SQL queries against a Stack Exchange database. The following query — select month(CreationDate) month, year(CreationDate) year, sum(case when lower(left(Title,2))='wh' then 1 else 0 end)/count(*) wh, (select sum(Score)/count(*) from Posts u where month(CreationDate)=month(t.CreationDate) and year(CreationDate)=year(t.CreationDate) and lower(left(Title,2))='wh' and PostTypeId=1 -- question ) wh_score, sum(Score)/count(*) score, (select sum(AnswerCount)

Pointer address Arithmetic and Hex/Dec Conversion

耗尽温柔 提交于 2020-01-16 00:57:29
问题 I have a pointer address I obtained from the extern char etext , end and edata . I also obtained address of variables using &<Variable Name> . Both are hexadecimal pointer addresses. I need to do arithmetic on those addresses in decimal. How do I do so? I need to convert the address into an int in decimal so I can find size of memory segments by subtracting addresses. 回答1: Math is math. It doesn't matter what base you do it on. The computer is working only in base 2 anyway. Only during input

Convert decimal feet to feet and inches?

拟墨画扇 提交于 2020-01-15 11:37:01
问题 How would I go about converting a measurement from, for example, 12.5 feet to 12ft 6in? How would I created that second number which reads only the decimal place when multiplying by 12? right now I have double Measurement01 using other variables and some math to get me the feet in decimals. I send that to a textview with farf.setText(Measurement01 + " " + "ft"); Any help would be appreciated! 回答1: Substract the integer portion: float measurement = 12.5; int feet = (int)measurement; float

Convert decimal feet to feet and inches?

☆樱花仙子☆ 提交于 2020-01-15 11:36:31
问题 How would I go about converting a measurement from, for example, 12.5 feet to 12ft 6in? How would I created that second number which reads only the decimal place when multiplying by 12? right now I have double Measurement01 using other variables and some math to get me the feet in decimals. I send that to a textview with farf.setText(Measurement01 + " " + "ft"); Any help would be appreciated! 回答1: Substract the integer portion: float measurement = 12.5; int feet = (int)measurement; float