Skip to main content
Filter by
Sorted by
Tagged with
-2 votes
0 answers
279 views

I got stuck on an exercise. I really need your help guys! Exercise: Instructions Create 3 functions which work like the .filter, .map and .reduce array methods, but for the entries in the grocery ...
melis16's user avatar
  • 17
0 votes
0 answers
49 views

My project is having a problem with decimal rounding errors in Spark v3 compared to Spark v2, where rounding to second decimal place works fine in Spark v2 but Spark v3 rounds the values up or down (...
Elle Panahi's user avatar
0 votes
2 answers
64 views

For this example, I am working with the following data: Z_Value <- c(-0.6745, 0.6745) I'm using the following function and want to use 3 sig figs. (If I have results that are 999 or higher, I want ...
SharonP's user avatar
  • 59
0 votes
2 answers
66 views

I'm trying to round the output of some calculations to 3 or less decimal places, so they can stored compactly in a comma-delimited text file. That is 2 should be stored as 2 not 2.000, 3.14 should be ...
Anachronist's user avatar
  • 1,132
0 votes
1 answer
75 views

I'm trying to make a code for a simple calculator for a programming problem, and I can't figure out how the rounding works in this case. 1 + 0 + 0.0005 returns 1.000 but 2 + 1 + 0.0005 returns 3.001. ...
이석민's user avatar
1 vote
2 answers
146 views

I'm trying to understand the practical utility of the G9 format specifier in C# when dealing with round-tripping floating-point numbers. The book C#12 in a nutshell mentions that G9 is helpful to ...
FluidMechanics Potential Flows's user avatar
3 votes
2 answers
206 views

I stumbled upon a failing unit-test, that involves converting doubles to integers. The actual number that is converted is 1.234 * 1000., and the code basically boils down to: #include <iostream> ...
umläute's user avatar
  • 32.2k
2 votes
1 answer
116 views

Basically I want to create my own tools for developing a 2D top-down game and when it comes to collision detection I'm trying to implement the SAT method, but somehow my calculations seem to be way ...
Péter Marschall's user avatar
1 vote
1 answer
291 views

When writing shaders in HLSL, sometimes you can run into very large floating point numbers, and with large floating point numbers, they struggle to maintain precision. When I wrote the blow code, I ...
Charles Lohr's user avatar
  • 1,021
2 votes
1 answer
336 views

I'm using a Metal compute pipeline to render into a CAMetalLayer's drawable and keep running into problems with non-integer pixel formats resulting in a slightly noisy image, due to some apparent ...
Marcel Tesch's user avatar
0 votes
2 answers
75 views

There's something wrong with my understanding of either the round function in python or how doubles are represented in python. I find a very perplexing behavior when rounding numbers that have a ...
AXensen's user avatar
  • 101
0 votes
3 answers
167 views

I'm searching a table for an exact match on an amount column DOUBLE(10,2). Due to the database driver I'm using, I have to bind my amount as a string parameter. In general this works well, hoever this ...
Peter Scopes's user avatar
-1 votes
1 answer
75 views

I am incredibly new to java and this is the description for a lab I currently have: Statistics are often calculated with varying amounts of input data. Write a program that takes any number of non-...
thatlittlerose's user avatar
0 votes
1 answer
73 views

I want to model demographic changes within a population, using historical data going from 1986 until the present. My data covers a population divided into age cohorts of a single year: 0,1,2 ... 106+. ...
KjetilH's user avatar
  • 59
-1 votes
1 answer
90 views

Given an array of integers, calculate the ratios of its elements that are positive, negative, and zero. Print the decimal value of each fraction on a new line with places after the decimal. Note: ...
Leslie Castelan Chavez's user avatar
-1 votes
1 answer
118 views

I found that for some strings the NumberFormatter produces incorrect results, as in the example below. let input = "579.988" let formatter = NumberFormatter() formatter....
Andrew Adamovitch's user avatar
1 vote
2 answers
76 views

The following code has a precision error but I'm at a loss as to how to resolve it. Given an initial value set in dollar/gal of $3.95, when change the ChoiceBox to "dollars/liter" I get $1....
JimArkadian's user avatar
0 votes
0 answers
26 views

I have implemented an algorithm for alpha blending. It worked for some time, but soon I have noticed that I'm receiving some weird results in some specific cases. I have investigated and it turned out ...
Spook's user avatar
  • 26.2k
2 votes
1 answer
372 views

How to handle rounding errors in solidity code? Avoid precision loss or keep track of precision losses. Example, if i have some calculated(includes a division) factors stored in a variable when a user ...
0xDA5's user avatar
  • 31
0 votes
1 answer
400 views

My domain registrar asks for a phone number in the following format: +358.401234567 (where 358 is the country code, 40 is the area code and the rest is the local phone number). To me personally this ...
tpimh's user avatar
  • 578
2 votes
1 answer
144 views

I'm curious what the first input is which differentiates these two functions: from math import * def ilog2_ceil_alt(i: int) -> int: # DO NOT USE THIS FUNCTION IT'S WRONG return ceil(log2(i)...
JamesTheAwesomeDude's user avatar
-1 votes
2 answers
444 views

I’m experiencing a small issue when I’m trying to round the number 1.785m to two digits. The number can probably not be represented correctly using the decimal data type, since it’s still a floating ...
Jan Wiesemann's user avatar
0 votes
0 answers
75 views

I have thousands of data in an sheet which are actually head wise monthly revenue generated by my organisation. The data are all numeric and in unit figure. I have to generate report in thousand fig ...
Hirakjyoti Bir's user avatar
1 vote
2 answers
187 views

I am building an API and the system that I am using just uses midpoint rounding in PowerShell. I've come to find out that certain numbers still disobey this rule and my research as to why has proven ...
Gabe Stotler's user avatar
2 votes
2 answers
200 views

The following is my df: https://www.dropbox.com/s/nbez3esbo8fedmf/aapl.csv?dl=0 date ticker open high low close adjClose 2019-07-08 AAPL 50.2025 50.35 49.6025 50.005 48.516 ...
saga's user avatar
  • 775
5 votes
0 answers
176 views

Consider the following code func main() { var ( negativeTwoThirds = -2.0 / 3.0 negativeSix = -6.0 negativeThree = -3.0 ) for _, v := range []float64{...
Remi.b's user avatar
  • 18.4k
0 votes
0 answers
23 views

Trying to round student grades to nearest multiple of five. If grade is two or less closer to the round then that grade gets used. What is wrong with my current code Grade = input(23) Round_grade = (((...
sez222's user avatar
  • 1
5 votes
1 answer
219 views

Problem : I stumbled across a problem that has deep (and very impactful) consequences in the industry, and does not seem to be documented anywhere : It seems that in python, Matrix Multiplication (...
Jean Lescut's user avatar
  • 1,497
1 vote
1 answer
766 views

I am trying to implement F.linear function from scratch using Pytorch, but it returns a slightly different value from Pytorch library function. In my case, the difference is about 1e-5 to 1e-9. 1e-5 ...
Jenny I's user avatar
  • 101
0 votes
1 answer
91 views

Using R I am trying to compute the likelihoods of a vector of values. Some of these values are way off into the tails of the distributions. Rounding error appears to be causing the results to be ...
BasMts's user avatar
  • 3
0 votes
0 answers
63 views

Assume there is a table named somethings with a column value of type float. The schema is shown below. # == Schema Information # # Table name: somethings # # id :bigint not null, primary key ...
makoto_atarashi's user avatar
-1 votes
1 answer
75 views

#include <stdio.h> int main(void) { float interest_rate, amount_of_loan, monthly_payment, remain_payment; printf("Enter amount of loan :"); scanf("%f", &...
jincoder's user avatar
0 votes
1 answer
342 views

Column A contains floats that are rounded to two decimals. Column B contains float multipliers that should sum to ~1.00. Cn is calculated as ATOTAL * Bn - An. Column C contains floats rounded to two ...
Dointer3's user avatar
1 vote
4 answers
198 views

As a premise, I am aware that this problem has been addressed already, but never in this specific scenario, from what I could find searching. In a time-critical piece of code, I have a loop where a ...
BadHellie's user avatar
  • 325
3 votes
2 answers
992 views

Consider the following C++ code: #include <fenv.h> #include <iostream> using namespace std; int main(){ fesetround(FE_TONEAREST); double a = 0x1.efc7f0001p+376; double b = -...
Heygard Flisch's user avatar
3 votes
0 answers
69 views

Surely rounding is (one of) the mostly asked and resolved questions. With any pre-defined precision after decimal point e.g. 10 ^ N, one could easily do double round(double input) { static ...
Alex Suo's user avatar
  • 3,167
1 vote
0 answers
106 views

When looking around for a way to determine if a point [X,Y] is within or on a polygon [[X,Y],[X,Y],...] I am running into the issue where the upper bounds (maxX and maxY) are being ignored. Example: ...
Nardwe's user avatar
  • 11
1 vote
1 answer
139 views

According to official java doc, RoundingMode HALF_EVEN: Rounding mode to round towards the nearest neighbor unless both neighbors are equidistant, in which case, round towards the even neighbor. So ...
Avash Adhikari's user avatar
0 votes
1 answer
58 views

I am trying to match an expected output of "13031.157014219536" exactly, and I have attempted 3 times to get the value with different methods, detailed below, and come extremely close to the ...
NeonSilver2's user avatar
0 votes
1 answer
50 views

I am trying to produce a table for a manuscript. For this table, there are NA values, large values above 1,000, and values that are below 10. I'd like the numbers less than 10 to be rounded to 1 ...
Alex Young's user avatar
5 votes
1 answer
1k views

I'm implementing randomized rounding mode for evaluating numerical stability of floating point (FP) computations in C99 code. This is the idea of this computational chemistry work, but updated to ...
Gordon Kindlmann's user avatar
0 votes
0 answers
268 views

Q4 <-flights %>% filter(origin=="JFK") %>% group_by(month,day) %>% summarise(mean=round(mean(distance),digits=2)) %>% arrange(desc(mean)) %>% head(5) print(Q4)...
Bob Ceres's user avatar
0 votes
2 answers
116 views

It is well known floating-point computation is inexact. For example: In [64]: 1+1e-16 Out[64]: 1.0 In this case, I would like to know if there is a double number that is better than 1.0 for ...
zell's user avatar
  • 10.4k
5 votes
1 answer
579 views

I was experimenting with NLopt and created the following minimum working example, which consistently fails with RoundoffLimited: NLopt roundoff-limited: import numpy as np import nlopt dim = 1 def ...
user20010813's user avatar
0 votes
0 answers
56 views

I understand that floating-point computation is inherently inaccurate due to rounding errors. But how can I understand that it is sometimes accurate, sometimes inaccurate, like the following: In [58]: ...
zell's user avatar
  • 10.4k
-2 votes
2 answers
696 views

I know there are different questions like this; and I searched my question on stackoverflow and many other webs, and basically the easiest way to do this is using the round/2 function, but the round ...
Arturo's user avatar
  • 3
1 vote
1 answer
344 views

Recently I found a problem when uploading excel file to snow flake using SAS. My excel include 2 columns 1400 rows, in the first column only 11 rows have 2 decimal place, in the second column, most of ...
Yumeng Xu's user avatar
  • 267
3 votes
0 answers
50 views

I stumbled across following scenario where how rounding works does not make sense to me. new BigDecimal(9999.005).setScale(2, RoundingMode.HALF_UP) -- 9999.0 new BigDecimal(999.005).setScale(2, ...
user2769607's user avatar
0 votes
1 answer
337 views

i'm trying to convert a double into a real for some operations but i noticed an error. i have a macro for reading purposes, short is 4 bytes, and long is 8 bytes. this is the execution code : print*, ...
Daniel Bar's user avatar
3 votes
1 answer
90 views

When computing the dot-product of two nalgebra::Vector3 structs using specific values, I get the following behaviour (link to playground): use nalgebra::{Point3, Vector3}; // 0.31.0 fn dot(v1: ...
Nevsden's user avatar
  • 129

1
2 3 4 5
8