Questions tagged [math-functions]

40 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
  • 30,333
  • 19
  • 96
  • 184
27
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
  • 4,637
  • 6
  • 28
  • 50
22
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
  • 2,984
  • 6
  • 27
  • 45
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
  • 527
  • 1
  • 5
  • 15
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
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
  • 746
  • 4
  • 11
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
  • 393
  • 1
  • 4
  • 16
1
vote
2 answers

Finding the object property with the highest value where the property is a decimal

I'm currently using: last = Math.max.apply(Math, response.data.map((o: any) => { return o.name; })) to find the object with the highest 'name' value within response.data array. Despite 16.12 being the largest value, it returns 16.9 as I think…
Nats
  • 100
  • 1
  • 12
1
vote
1 answer

Which sigmoid function to use for increasing contrast of an image?

Is there a standard sigmoidal function used to increase the contrast in a gray level bitmap? Currently I am using the following. This would be applied to gray levels represented at values between 0 and 1 inclusive. static double ContrastCurve(double…
jwezorek
  • 3,125
  • 1
  • 19
  • 30
1
vote
0 answers

What is the fastest fabsf (floating point absolute value function) implementation in c#?

I am in the process of optimizing the most demanding function in a Unity 3d game. The most costly subroutine is the unity Mathf.Abs method which is being called on floating point values(NEVER DOUBLES). In cases, calls to this function are adding…
1
vote
2 answers

Get the min and max value in android studio

what I am trying to do, is get the minimun and maximun value from some float values I put manually. But I do not know how to do it. any helping coidng would be great. Thank you. Asume a list of floats p1, p2, p3, p4, p5, p6, p7, p8, p9
jvargas
  • 526
  • 4
  • 10
1
vote
1 answer

How can I temporary or permanently change the math formula colors in Wikipedia pages?

The question in the caption is sufficiently verbose imho. The background for it is my dark browser theme (I hate bright whites) in which black text (e.g. the Wikipedia-math-formulas) are not readable. Further info: the said formulas are svg-files…
Steffen W.
  • 21
  • 4
1
vote
2 answers

C# trigonometric functions / math functions

I'm writing a class which should calculate angles (in degrees), after long trying I don't get it to work. When r = 45 & h = 0 sum should be around 77,14° but it returns NaN - Why? I know it must be something with the Math.Atan-Method and a not…
maddy
  • 13
  • 3
1
vote
1 answer

unity Mathf.PerlinNoise not between 0 and 1

Does anybody know why this: Debug.Log(Mathf.PerlinNoise(190911.45f, 2290937.40f)); gives me: 1.044323 It should have been between 0 and 1 isn't it? And if it can get bigger than 1 can it get smaller than 0? I'm making a map with sprites…
1
vote
1 answer

Using Mathf.Clamp without effecting y axis.

I have a script that makes my camera follow the mouse. Works fine but I want the camera to only be able to move so far so I used this. transform.position = new Vector3(Mathf.Clamp(transform.position.x, 1.5f, -1.4f), 0, -10); It works to stop the…
1
2 3