digits

How can I tell R to round correctly?

懵懂的女人 提交于 2019-12-12 14:18:22
问题 How can I tell R to round correctly? Decimal Places in R I have encountered a problem that I cannot figure out how to solve I want R to calculate 5/26*100 = 19.230769 x <- 5/26*100 x gives me: [1] 19.23077 Let's try to use round(), first setting the digits to 4: x <- round(5/26*100,digits=4) x gives: [1] 19.2308 Next, let's set the digits to 5: x <- round(5/26*100,digits=5) x gives: [1] 19.23077 Now, let's set the digits to 6: x <- round(5/26*100,digits=6) x gives: [1] 19.23077 Can anyone

Tesseract has trouble reading this extremely simple string of numbers

偶尔善良 提交于 2019-12-12 12:33:11
问题 I'm currently writing a script in python that requires the use of tesseract to read a number like this: Using digits only and -psm 6 (or 7) it outputs 5.551 I have had some success with other numbers (5.700 works) but this particular number is giving me a ton of problems. Unfortunately i need a high degree of accuracy for my program but i thought tesseract would be able to decipher such a simple string. I have also tried to use GOCR and that correctly read 6.881 (yay!) but gave the output 5.

Using django haystack autocomplete with elasticsearch to search for digits/numbers?

雨燕双飞 提交于 2019-12-12 09:51:42
问题 I'm using Django Haystack backed by Elasticsearch for autocomplete, and I'm having trouble searching for digits in a field. For example, I have a field called 'name' on an object type that has some values like this: ['NAME', 'NAME2', 'NAME7', 'ANOTHER NAME 8', '7342', 'SOMETHING ELSE', 'LAST ONE 7'] and I'd like to use autocomplete to search for all objects with the number '7' in the name. I've set up my search_index with this field: name_auto = indexes.EdgeNgramField(model_attr='name') and I

Code Golf: ASCII Art number [duplicate]

一曲冷凌霜 提交于 2019-12-11 12:34:34
问题 This question already has answers here : Closed 9 years ago . Possible Duplicate: Code Golf - Banner Generation Post your shortest code to convert a number into a ASCII art digits. Input - Assume that an integer variable called z has already been set containing the number. Output - Print the output to the console. Quality - The lower number of characters, the better. Formatting - Flexible, providing it is ASCII art and looks like a number. There must also be some spacing between digits. Test

mathjax commas in digits

﹥>﹥吖頭↗ 提交于 2019-12-11 09:14:18
问题 This is a TeX legacy issue---it would have made more sense to require a whitespace when a whitespace is desired: 12,123 is probably a number, while 12, 123 is probably a list. Alas, it is what it is. Related to MathJax rendering of commas in numbers, where the solution is suppression of spaces via {,} . Works, but inconvenient. Is there a way to make this automatic? The hack in https://github.com/mathjax/MathJax/issues/169#issuecomment-2040235 is concerned with European vs Anglo. The

program displaying to few digits

家住魔仙堡 提交于 2019-12-11 05:37:29
问题 This program computes the square root of 2, but it will not display the digits to my desired accuracy of 1000 digits, but instead it only displays 50 digits. here is the program import math a=format(2.0**0.5, '.1000') print a I would like to know how to write a program to display more digits. 回答1: Use the decimal module: >>> from decimal import * >>> getcontext().prec = 100 >>> Decimal(2).sqrt() Decimal('1

Given a number series, finding the Check Digit Algorithm…?

纵饮孤独 提交于 2019-12-11 03:35:40
问题 Suppose I have a series of index numbers that consists of a check digit. If I have a fair enough sample (Say 250 sample index numbers), do I have a way to extract the algorithm that has been used to generate the check digit? I think there should be a programmatic approach atleast to find a set of possible algorithms. UPDATE: The length of a index number is 8 Digits including the check digit. 回答1: No, not in the general case, since the number of possible algorithms is far more than what you

Return sum of a number (positive or negative)

青春壹個敷衍的年華 提交于 2019-12-11 03:24:06
问题 I need to make a function that takes a number and returns sum of it's digits, if the number is negative the first digit should be considered negative when adding numbers, this is what I have: var arrx = []; var oper; var others = 0; function sumDigits(num) { // your code here var y = num.toString(); var c = y.split(""); c.forEach((h) => arrx.push(Number(h)) ); if (num < 0){ oper = -arrx[0]; for (var z = 1; z < arrx.length; z++){ others += arrx[z]; } return others + oper; } return arrx.reduce(

Fixed digits number in floats

本小妞迷上赌 提交于 2019-12-11 01:09:38
问题 I read a lot of discussion about this on SE, but still can't find the right one. I want to plot some numbers, of various lengths, with the same number of digits. For example I have: 12.345678 , 1.2345678 . Now, since I have to plot them with their error, I want that each one has a different format, in order that they are significant. So, I want to plot them with a variable number of decimals. In my case, it makes no sense to plot 23.45678+/-1.23456 but better is 23.4+/-1.2 . On the other hand

why is there significant double precision difference between Matlab and Mathematica?

我与影子孤独终老i 提交于 2019-12-11 00:07:30
问题 I created a random double precision value in Matlab by x = rand(1,1); then display all possible digits of x by vpa(x,100) and obtain: 0.2238119394911369 7971853298440692014992237091064453125 I save x to a .mat file, and import it into Mathematica, and then convert it: y = N[FromDigits[RealDigits[x]],100] and obtain: 0.2238119394911369 0000 Then go back to Matlab and use (copy and paste all the Mathematica digits to Matlab): vpa(0.22381193949113690000,100) and obtain: 0.22381193949113689