Problem with large decimal places in Excel - excel-2016

I'm currently trying to upload a multi-sheet excel document to a web-based application but running into an issue with floating-point numbers being added to the sum (see attached pictures). The total of the percentage values should add up to 100, however, they do not. The sum at 12 decimal places is 100.000000000000:
but when the decimal place is extended to 13 it is 99.9999999999999:
The web application I'm uploading to is reading it at 13 decimal places or higher from excel. I truly only need 6 decimal places but can't find a working solution. The round and absolute function have proven ineffective as well as the advanced option "set precision as displayed". Is it possible to adjust excel to sum at 6 decimal places or a specified amount?
I'm using Excel 2016.
And the data is as follows. (92) rows of the value 1.075268. (1) row of the value 1.075344.
Any advice or recommendations would be greatly appreciated. Please let me know if I need to elaborate on anything.

Apparently this has nothing to do with the values you enter or how the cells containing them are formatted regarding decimal places, but with how Excel stores them internally and displays them:
[Don't get confused by the decimal commas usual here.]
If you look at <the>.xslx/xl/worksheets/sheet1.xml with a ZIP-program:
...
<c r="A1" s="1">
<v>1.0753440000000001</v> ... displayed as 1,075344‾0
</c>
<c r="A2" s="1">
<v>1.0752679999999999</v> ... displayed as 1.075268‾0
</c>
...
<c r="C2" s="11">
<f>SUM(A:A)</f>
<v>99.999999999999844</v> ... displayed as 100.‾0
</c>
...
<c r="E1" s="9">
<v>1</v>
</c>
<c r="E2" s="9">
<v>1.1000000000000001</v> ... displayed as 1.1‾0
</c>
...
<c r="F11" s="14">
<f>SUM(E:E)</f>
<v>99.999999999999872</v> ... displayed as 99.999999999999‾0
</c>
...
<c r="K1" s="9">
<v>91.2</v>
</c>
<c r="K2" s="9">
<v>1.1000000000000001</v> ... displayed as 1.1‾0
</c>
...
However, as Martheen mentioned in the comment to your question, you don't send the sum but the individual values to your application anyway.

Related

Optaplanner: Howto change the sample XML in the nurserostering demo?

I am stucked with the Nurserostering example in Optaplanner. I would like to change the input XML to play around (for example increase the number of nurses from 30 to 100), and I find it's very complicated to manually edit it, so I think there must be some kind of 'generator', or maybe I should make my own 'XML generator'.
For example I see every node in the sample has a unique id, so if I want to increase the number of nurses, it's not as simple as copying the last Employee node and pasting it 70 times; I should check every id inside and increase it accordingly.
<Employee id="358">
<id>6</id>
<code>6</code>
<name>6</name>
<contract reference="36"/>
<dayOffRequestMap id="359">
<entry>
<ShiftDate reference="183"/>
<DayOffRequest id="360">
<id>18</id>
<employee reference="358"/>
<shiftDate reference="183"/>
<weight>1</weight>
</DayOffRequest>
...
Therefore, I ask, is there any method to generate this (or other) XML?
The best way I could think of is write a small java application where you could load the original dataset, and then add any number of employees you want (using java code of course). At least this is what I do when I need a bigger dataset or when I toy around the model data (because the dataset need to be updated too).
Oh I almost forgot, sometimes I use xml viewer to help me do some manual copy and paste work (it help me a lot since the row is thousand lines).
You looked at the wrong XML file! Instead of taking e.g. data/nurserostering/unsolved/medium01.xml, take data/nurserostering/import/medium01.xml.
<Employees>
<Employee ID="0">
<ContractID>0</ContractID>
<Name>0</Name>
<Skills>
<Skill>Nurse</Skill>
</Skills><
</Employee>
[...]
<DayOffRequests>
<DayOff weight="1">
<EmployeeID>0</EmployeeID>
<Date>2010-01-21</Date>
</DayOff>
[...]
This file can then easily be edited and imported in OptaPlanner.

Can I use Oracle 11g's updatexml function to insert a value into an element without also adding the namespace to the tag that I'm inserting?

Let's say that I have many XML documents similar to the following XML document:
<a xmlns="urn:www.someSite.com/myModel">
<b>
<c>my value</c>
</b>
<d>
<e>my other value</e>
<f>even more other values</f>
</d>
</a>
And I want the document instead to look like this:
<a xmlns="urn:www.someSite.com/myModel">
<b>
<e>my other value</e>
<f>even more other values</f>
</b>
<d>
<e>my other value</e>
<f>even more other values</f>
</d>
</a>
For the sake of argument, let's say these documents are in the table MY_TABLE, in column XML_DOCUMENT_COLUMN. For the sake of simplicity there's also a PRIMARY KEY column on the table called MY_TABLE_KEY.
Using Oracle 11g's UpdateXML function, I can write the following query:
update MY_TABLE mt
set mt.XML_DOCUMENT_COLUMN = (
select updatexml(
mt.XML_DOCUMENT_COLUMN,
'/a/b',
'<b>' || extract(
mt1.XML_DOCUMENT_COLUMN,
'/a/d/*',
'xmlns="urn:www.someSite.com/myModel"'
).getStringVal() || '</b>',
'xmlns="urn:www.someSite.com/myModel"')
from MY_TABLE mt1
where mt1.MY_TABLE_KEY = mt.MY_TABLE_KEY
)
Long story short, what this says is "update the column with this altered version of the column where the key is the same."
The problem is that this always returns a document that looks like this:
<a xmlns="urn:www.someSite.com/myModel">
<b xmlns="urn:www.someSite.com/myModel">
<e>my other value</e>
<f>even more other values</f>
</b>
<d>
<e>my other value</e>
<f>even more other values</f>
</d>
</a>
Now, for various reason, I'm not sure that some other code won't break because of a new xmlns declaration in the middle of the document, so I would really like to remove that before running this on my database. I thought the answer would be to just drop the namespace tag in the UpdateXML call, but after running that as a query, I found that no documents in the database changed.
So finally, the question is - how do I update the document to look like the second document, can I do it with one query, and what does that query look like? Bonus round: what am I doing wrong, and what does the xmlns argument to the UpdateXML function do?
Note: The XML documents and XPaths have been changed to protect guilty parties, and to obscure the project that I'm working on. As such, some of this information may not be accurate, as I'm trying to cross-compile XPaths in my head. I'll change the question to provide any clarification that I can.

Big Commerce API - Leading zero in SKU is trimmed

When creating items in Big Commerce from the API, if sku provided is a string of numbers and if there are leading zeroes, the leading zeroes will be trimmed. For example sku "01234" will become "1234".
<skus>
<sku>01234</sku>
<upc>01234</upc>
<cost_price>17.9800</cost_price>
<inventory_level>1</inventory_level>
<options>
<option>
<product_option_id>4778</product_option_id>
<option_value_id>2113</option_value_id>
</option>
</options>
</skus>
I was wondering if anyone has encountered this before and managed to do some work-around. Please let me know.
Thanks

Struts Formatting

I am trying to format a double value to two decimal places in a struts <html:text> tag. ex)
<html:text property="freight" size="9" maxlength="9" />
the value inside freight is a double for example $100. When it displays, it shows it as 100.0, not 100.00 (like I want it to).
I would like to display all double values to two decimal places but the <html:text> does not have a format property.
Could someone please help?
You can use <s:text> tag to do it.
Add a formatting entry to a .properties file (probably package.properties)
format.twodecimalnumber={0,number,#0.00}
Then in your view (JSP) file, the following code can be used for displaying a formatted number
<s:text name="format.twodecimalnumber">
<s:param name="value" value="53.3" />
</s:text>
If you want the formatted number to be displayed in an input textbox, you can wrap the above code inside a <s:textfield> tag. Like so -
<s:textfield>
<s:param name="value">
<s:text name="format.twodecimalnumber">
<s:param name="value" value="53.3" />
</s:text>
</s:param>
</s:textfield>
Refer https://struts.apache.org/release/2.0.x/docs/formatting-dates-and-numbers.html

HTML text field not displaying decimal places of SQL money value

I have a text field who's value is populated from a SQL recordset (below).
<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10" value="<%=RS("Amount")%>">
In the SQL table, the Amount field (which is a money data type) is inserted correctly, as 5.00 However, in the web page, it displays only as 5 (i.e. the decimal places are missing). Anyone know why this might be and how I can get the decimal places to display in the field? Thanks!
If you don't want the dollar sign, use
value="<%=FormatNumber(RS("Amount"),2)%>"
Applying formating will do the trick:
<input name="txtAmount" id="txtAmount" type="text" size="10" maxlength="10"
value="<%=FormatCurrency(RS("Amount"), 2)%>">
If your code is in .NET, you can use
<%= String.Format("{0:0.00}", RS("Amount")) %>