Google Code Jam 2008: Round 1A Question 3

At Google Code Jam 2008 round 1A, there is problem: Calculate last three digits before the decimal point for the number (3+sqrt(5))^n n can be big number up to 1000000. For example: if n = 2...

Regex to replace everything except numbers and a decimal point

I have a text field that needs to remain only text or decimal. Here is the code that I'm currently using to replace everything except numbers and a decimal point. Issue is, I can't figure out a...

How to extract a floating number from a string

I have a number of strings similar to Current Level: 13.4 db. and I would like to extract just the floating point number. I say floating and not decimal as it's sometimes whole. Can RegEx do this...

How do I get the decimal places of a floating point number in Javascript?

What I would like to have is the almost opposite of Number.prototype.toPrecision(), meaning that when i have number, how many decimals does it have? E.g. (12.3456).getDecimals() // 4

How to round to at most 2 decimal places, if necessary?

I'd like to round at most 2 decimal places, but only if necessary. Input: 10 1.7777777 9.1 Output: 10 1.78 9.1 How can I do this in JavaScript?

How can I make a WPF TextBox care about a decimal point?

So I have a TextBox that only allows numbers and decimal points. I want the user to only be allowed to enter 1 decimal point. Here is the code that is triggered on the PreviewTextInput event:...

PostgreSQL - rounding floating point numbers

I have a newbie question about floating point numbers in PostgreSQL 9.2. Is there a function to round a floating point number directly, i.e. without having to convert the number to a numeric type...

SqlBulkCopy - The given value of type String from the data source cannot be converted to type money of the specified target column

I'm getting this exception when trying to do an SqlBulkCopy from a DataTable. Error Message: The given value of type String from the data source cannot be converted to type money of the specified...

fp32 to fp16 and reverse conversion - Matlab or C++ code

I have a decimal number (such as 0.15625) which is stored as 32-bit floating point (fp32) number (0-01111100-01000000000000000000000 (sign-exponent-mantissa)) in memory. I want to convert that...

With `pandas.cut()`, how do I get integer bins and avoid getting a negative lowest bound?

My dataframe has zero as the lowest value. I am trying to use the precision and include_lowest parameters of pandas.cut(), but I can't get the intervals consist of integers rather than floats with...

Formatting Numbers So They Align On Decimal Point

In Python, I need to format numbers so they align on the decimal point, like so: 4.8 49.723 456.781 -72.18 5 13 Is there a straighforward way to do this?

Reconciling exponential function results in C++ (Rcpp) and R

I am working on speeding up software from my dissertation by utilizing Rcpp and RcppEigen. I have been very impressed with Rcpp and RcppEigen as the speed of my software has increased by upwards...

Access linked tables truncating my Decimal values from the SQL server

Since migrating the Access data to a SQL server I am having multiple problems with the decimal values. In my SQL tables on the SQL 2012 server I am using the Decimal data type for multiple fields....

Formatting floating point number in Python with padding of 0s

Python, version 2.7.3 on 64-bit Ubuntu 12.04 I have a floating point number between 0 and 99.99. I need to print it as a string in this format: WW_DD where WW are whole digits and DD are the...

R: Calculate and interpret odds ratio in logistic regression

I am having trouble interpreting the results of a logistic regression. My outcome variable is Decision and is binary (0 or 1, not take or take a product, respectively). My predictor variable is...

How to round/remove trailing ".0" zeros in pandas column?

I'm trying to see if I can remove the trailing zeros from this phone number column. Example: 0 1 8.00735e+09 2 4.35789e+09 3 6.10644e+09 The type in this column is an object, and...

Fixed digits after decimal with f-strings

Is there an easy way with Python f-strings to fix the number of digits after the decimal point? (Specifically f-strings, not other string formatting options like .format or %) For example, let's...

Currency exchange rate java assignment

Hello I am looking for help on my homework assignment! So the prompt is as follows: " Write a program that prompts the user to enter the exchange rate from currency in US dollars to Chinese RMB....

Where are the inaccuracies in math.sqrt() and math.pow() coming from for large numbers?

If you take a number, take its square root, drop the decimal, and then raise it to the second power, the result should always be less than or equal to the original number. This seems to hold true...

Two way data binding with two EditText views

I'm having trouble making two Edit Text views that update when one is changed. To provide some context, see the following image: Also the view in action (can't have it embedded...

Python regex to extract positive and negative numbers between two special characters

Need to extract value from a string, the value can contain a comma, a decimal point, both comma and decimal point, without any of comma or decimal point, with any of comma or decimal. For...

The method 'call' was called on null. Receiver: null

I have just started working on the flutter application and I am getting this kind of exception on pressing save button. The method 'call' was called on null. Receiver: null Tried calling:...

How to show exactly 4 numbers after decimal point without rounding in Python?

I want to calculate square root of numbers and print them with exactly 4 numbers after decimal point without rounding. This code rounds the numbers num="%.4f" % num and this one doesn't show...

remove decimal in dart

I have a number: 466.62 as a double and can't change it to a string, how can I get rid of the decimal point and print 46662? I've managed to get 46662.0 by multiplying the value by 100, but I...

Is there an python function or extension that is is similar to Matlab's format short?

The command format short in Matlab makes all the print outs in the command window be "Short, fixed-decimal format with 4 digits after the decimal point." I know there is np.round, but I would like...

Norms in Python for floating point vs. Decimal (fixed-point)

Is it recommended to use Python's native floating point implementation, or its decimal implementation for use-cases where precision is important? I thought this question would be easy to answer:...

REGEX Extract Amount Without Currency

SELECT ocr_text, bucket, REGEXP_EXTRACT('-?[0-9]+(\.[0-9]+)?', ocr_text) FROM temp I am trying to extract amounts from a string that will not have currency present. Any number that...

Copy decimal into byte array without allocations

The Dream I'm looking for a way to copy a decimal value into a byte array buffer and then be able to read those bytes back into a decimal without any heap allocations. Ideally this wouldn't...

how to get value Http Get Request with parameter in flutter

I already create Get Request with 3 parameter in postman I tried this in flutter but it didnt showing the data to listview I already tried with hard code its working fine. but when i input this...

Contract returns totalSupply from Solidity as BigNumber but need to validate it without the decimals

Solidity returns totalSupply() as 1 trillion + the 9 decimals as 1trillion concat with 9 zeroes. So when I try to do a mocha test to check the supply is 1T, it fails because the number has 9 extra...