decimal-point

Change decimal separator in GDB

和自甴很熟 提交于 2019-12-12 12:23:26
问题 Is there a way to change decimal separator in gdb, without changing it in the whole system? I have a French ubuntu 14.04 (with comma as decimal separator). But in gdb, any floating point written with a dot (for example p 2.0 ) leads to "invalid number" message; and comma is interpreted as list separator... I have tried to create a gdbinit file with set environment LC_NUMERIC="C" within, but it didn't work... 来源: https://stackoverflow.com/questions/24865689/change-decimal-separator-in-gdb

Sorting records from Oracle with multiple decimal points (.)

故事扮演 提交于 2019-12-12 08:36:00
问题 UPDATE: ORACLE VERSION 10G I have a list of records in Oracle as follows, these are actually sections of various books The records are generated in the below format [main topic].[sub topic].[first level section] ..... .[last level section] Sections -------- 1 7.1 6.2 7.1 7.4 6.8.3 6.8.2 10 1.1 7.6 6.1 11 8.3 8.5 1.1.2 6.4 6.6 8.4 1.1.6 6.8.1 7.7.1 7.5 7.3 I want to order this like as follows 1 1.1 1.1.2 1.1.6 6.2 6.4 6.5 6.6 6.7 6.8.1 6.8.2 6.8.3 7.2 7.3 7.4 7.5 7.6 7.7.1 7.7.2 8.3 8.4 8.5 10

In Java, why does the decimal separator follow the Locale's language, not its country, and, more importantly, how does one override it?

自古美人都是妖i 提交于 2019-12-12 08:34:47
问题 I'm working on an international project and have observed that, in Java, the choice of the decimal separator is based on the Locale's language, not its country. For example: DecimalFormat currencyFormatter = (DecimalFormat) NumberFormat.getInstance(new Locale("it","IT")); System.out.println(currencyFormatter.format(-123456.78)); currencyFormatter = (DecimalFormat) NumberFormat.getInstance(new Locale("en","IT")); System.out.println(currencyFormatter.format(-123456.78)); produces the following

Formatting Integer with a decimal point

穿精又带淫゛_ 提交于 2019-12-12 04:58:15
问题 I have an integer value that is read from a PLC device via bluetooth and the first digit represent one decimal place. For example: 100 must be formatted to 10.0. Another examples: 500 -> 50.0 491 -> 49.1 455 -> 45.5 The following line will make it okay: data11.put("Text2", String.format("%.1f", (float)(mArray[18] & 0xFF | mArray[19] << 8) / 10.0)); But... Is there another way to do the same using String.format without divide by 10.0? Thank you 回答1: How about the following way? x = x.substring

decNumber library - compile issues

China☆狼群 提交于 2019-12-11 04:43:12
问题 I am having issues compiling the decNumber http://speleotrove.com/decimal/, source is here http://download.icu-project.org/files/decNumber/decNumber-icu-368.zip (includes examples etc. that need to be deleted) Has anyone compiled this successfully? Your comments will be much appreciated!! The compiler issues an error as a result of the following directives: #if !defined(QUAD) #error decBasic.c must be included after decCommon.c #endif (This is a small section of code from decCommon.c and

mssql display 1 decimal point if available, else show none

删除回忆录丶 提交于 2019-12-11 02:33:25
问题 Simple one I think. I have a query that shows lengths of items. Query: select length from vw_OutstandingVsInStock1 OVI LEFT JOIN Departments DEP on OVI.Department COLLATE DATABASE_DEFAULT=DEP.Description where OutstandingVolume>0.39 This returns results like: 0.9 1.2 1.5 1.8 2.1 2.4 2.7 3.0 3.3 3.6... In the case of 3.0 I want it to display as 3 so if no decimal value, show int with no decimals. if a decimal exists show decimal to 1 decimal point? so desired output is 3 and 6 instead of 3.0

What's the best technique for handling US Dollar calculations in Perl?

时光毁灭记忆、已成空白 提交于 2019-12-10 18:08:16
问题 What's the best technique for handling US Dollar calculations in Perl? Especially: the following needs to work: $balance = 10; $payment = $balance / 3; # Each payment should be 3.33. How best to round amount? $balance -= $payment * 3; # assert: $balance == .01 回答1: See Math::Currency. Updated: Assuming all payments adding up to the balance is desirable, I came up with the following script based on the points made by Greg Hewgill: #!/usr/bin/perl use strict; use warnings; use List::Util qw(

Determine the decimal precision of an input number

♀尐吖头ヾ 提交于 2019-12-10 02:48:57
问题 We have an interesting problem were we need to determine the decimal precision of a users input (textbox). Essentially we need to know the number of decimal places entered and then return a precision number, this is best illustrated with examples: 4500 entered will yield a result 1 4500.1 entered will yield a result 0.1 4500.00 entered will yield a result 0.01 4500.450 entered will yield a result 0.001 We are thinking to work with the string, finding the decimal separator and then calculating

Format a number containing a decimal point with leading zeroes

你离开我真会死。 提交于 2019-12-09 16:24:03
问题 I want to format a number with a decimal point in it with leading zeros. This >>> '3.3'.zfill(5) 003.3 considers all the digits and even the decimal point. Is there a function in python that considers only the whole part? I only need to format simple numbers with no more than five decimal places. Also, using %5f seems to consider trailing instead of leading zeros. 回答1: Starting with a string as your example does, you could write a small function such as this to do what you want: def zpad(val,

How to properly display a price up to two decimals (cents) including trailing zeros in Java?

左心房为你撑大大i 提交于 2019-12-09 06:08:06
问题 There is a good question on rounding decimals in Java here. But I was wondering how can I include the trailing zeros to display prices in my program like: $1.50, $1.00 The simple solution of String.format("%.2g%n", 0.912385); works just fine, but omits the trailing zero if it is at the last decimal place. The issue comes up in my program even though I only use expressions like this: double price = 1.50; When I do calculations with different prices (add, multiply, etc.) the result is primarily