Questions tagged [math-functions]
56 questions
47
votes
1 answer
What exactly is std::labs() there for?
I read about the std::abs() function when browsing cppreference.
On that page I have also seen a std::labs() function. Which has the same prototype as one of the std::abs() overloads (the one for long).
long abs( long n );
long labs( long n );
and…

msc
- 33,420
- 29
- 119
- 214
35
votes
2 answers
Math functions in angular2 bindings
Is there a way to use math functions in angular2 bindings?
example
{{Math.round(variable/12*2)}}
{{Math.round(variable/12*2)}}
…

Jagadeesh Govindaraj
- 6,977
- 6
- 32
- 52
23
votes
5 answers
Function to Remove the Decimal Places
What is the JavaScript Math.Floor() equivalent in VBA?. this function should remove all the decimal places and return only an integer.

Sami Al-Subhi
- 4,406
- 9
- 39
- 66
20
votes
3 answers
Need help rounding to 2 decimal places
Why is it that when I do the following...
Math.Round(0.75, 1, MidpointRounding.AwayFromZero)
I get 0.8
but when I do the following...
Math.Round(0.575, 2, MidpointRounding.AwayFromZero)
I don't get 0.58. Instead I get 0.57. I want anything that is…

Steve B
- 557
- 2
- 7
- 23
8
votes
1 answer
Which functions are affected by -fno-math-errno?
I have been excited by this post: https://stackoverflow.com/a/57674631/2492801 and I consider using -fno-math-errno. But I would like to be sure that I do not harm the behaviour of the software I am working on.
Therefore I have checked the (rather…

Benjamin Bihler
- 1,612
- 11
- 32
4
votes
2 answers
POWER does not reverse LOG and vice versa
The problem I have with POWER/LOG is that although they seem to adapt to the data-type you send in (the output variable type matches the first variable's type), the precision seems to stop close to the limits of a float, resulting in incorrect…

Keith Zink
- 41
- 3
3
votes
1 answer
Why is Boost implementation 5-10x slower than R's
I am building an app that frequently computes the regularized incomplete beta function. The app is written in C++ and calls R::pbeta(). When I tried to multithread the app, some warning messages from R::pbeta() smashed the stack.
So I turned to…

user2961927
- 1,290
- 1
- 14
- 22
3
votes
3 answers
Error when importing mathematics in Unity3d
When I try to import mathematics it throws me an error saying that
'' error CS0234: The type or namespace name 'Mathematics' does not exist in the namespace 'Unity' (are you missing an assembly reference?)''
I tried, Using System.Mathematics, Using…

Fame Star
- 45
- 1
- 6
2
votes
1 answer
Swift: calculating atan2(y,x) for FloatingPoint numbers?
If the only thing I know about the variables x, y is that they are of type T which is conforming to the FloatingPoint protocol, how can I calculate the value of atan2(y, x) and return it as an instance of type T?
Actually, I was trying to implement…

lochiwei
- 1,240
- 9
- 16
2
votes
1 answer
Graphing function from string doesn't evaluate correctly at 0
I'm trying to create a grapher using matplotlib.pyplot and want to graph a function that comes like a string
import matplotlib.pyplot as mpl
import numpy as np
def plot2D(*args):
mpl.grid(1)
xAxis = np.arange(args[1],args[2],args[3])
…

Secozzi
- 252
- 3
- 10
2
votes
0 answers
Graphing functions ReactJS
I am looking for a graphing library that can be used to graph functions, not data points. I have searched for a graphing library that:
graphs mathematical functions, rather than data points (both is fine as long as it does the first)
is…

Ryan Cocuzzo
- 3,109
- 7
- 35
- 64
2
votes
1 answer
unity c# Mathf.FloorToInt(-0.5) returns 0 (acts like Mathf.CielToInt)
Here's the script reference document for Mathf.FloorToInt As you can see, it should round -0.5 down to -1. For some reason it seems to return it as 0 when used with my calculations.
I have two versions of the same functions that work in a very…

IAmJersh
- 742
- 8
- 25
1
vote
1 answer
How do I add values to my graph in core plot swift?
let graph = CPTXYGraph(frame: hostview.bounds)
hostview.hostedGraph = graph
graph.paddingLeft = 0.0
graph.paddingTop = 0.0
graph.paddingRight = 0.0
graph.paddingBottom = 0.0
graph.axisSet =…

Gabriel
- 37
- 4
1
vote
1 answer
Unit Test Mathf.Sine C# / Unity
I am trying to write down a unit test to check if a new vector3 returns (cos(angle), 0, sin(angle)). So if pass angle = 0, it should returns (1,0,0).
I know it is something related to the Episilon, but I don't know how to formulate it.
Here is my…
1
vote
1 answer
Mathf.PingPong from 1 to 0
I have created a helper to PingPong from 1 to 0, but I'm having a hard time inverting this, so that the value goes from 1 to 0.
Below you can see the code, I'm currently using. I'm also not sure if this is even possible.
_lerpPulse =…

Quincy Norbert
- 431
- 1
- 6
- 18