Call to undefined function pi() [duplicate] - c++builder

This question already has answers here:
How to use the PI constant in C++
(25 answers)
Closed 5 years ago.
I am using Borland C++Builder 3.
I have included math.h in my code.
When using this code:
float b;
b=pi();
I get the following compiler error:
call to undefined function pi()

Use the M_PI constant, not the pi() function.

Related

Get uint64_t out of __m128 intrinsic? [duplicate]

This question already has answers here:
C++ SSE Intrinsics: Storing results in variables [closed]
(1 answer)
print a __m128i variable
(4 answers)
SSE: Difference between _mm_load/store vs. using direct pointer access
(3 answers)
How to extract bytes from an SSE2 __m128i structure?
(1 answer)
Is `reinterpret_cast`ing between hardware SIMD vector pointer and the corresponding type an undefined behavior?
(2 answers)
Closed 1 year ago.
I can use _mm_set_epi64 to store two uint64_ts into a __m128 intrinsic. But hunting around, I see various ways to get the values back out: There's reinterpret_cast (and it's evil twin C-style casts), it's sibling union { __m128; uint64[2]; }; and memcpy, there's accessing fields of __m128. There's __m128i _mm_load_si128(__m128i *p);, but I'm not seeing a _mm_get_* function. Am I missing something? If there's a _mm_set_epi64 then there must be a non-cast way to get the uint64_ts back out, right? (Otherwise why would they bother providing _mm_set_epi64?)
I see Get member of __m128 by index? but the "correct answer" has a broken link and implies there's a load function, but all the loads I see map __m128 to __m128. Shouldn't there be a void _mm_get_epi64(__m128, uint64_t* outbuf)?

Trying to understand a "C-style" statement in swift 3 [duplicate]

This question already has answers here:
Swift 3 for loop with increment
(5 answers)
Replacement for C-style loop in Swift 2.2
(4 answers)
Express for loops in swift with dynamic range
(2 answers)
Closed 5 years ago.
I am self-learning to program and I came across this piece of Swift 2.0 code.
someFunction {
for var i = N; i >= 1; i -= 1 {
//...
}
}
This is a "C-Style" code apparently. What exactly is happening in this control flow? Are we starting from N, and subtracting 1 until we get to equal/greater than 1?
Or does the i >= 1 mean that the iteration count must ALWAYS be greater than or equal to one?

How we can write for loop syntax in swift 3.0 [duplicate]

This question already has answers here:
#warning: C-style for statement is deprecated and will be removed in a future version of Swift [duplicate]
(4 answers)
Fix warning "C-style for Statement is deprecated" in Swift 3
(4 answers)
Closed 6 years ago.
How we can differentiate for loop and for each loop in swift language ?
do like
for i in 0..<100 {
print("Number \(i)")
}
for more sample, you can get here
If you want to do it with some step, just use it (step is 2):
for i in stride(from: 0, to: 100, by: 2) {
print(i)
}

Obj-c Expression error - Invalid operands to binary expression ('CGFloat' (aka 'double’)) [duplicate]

This question already has answers here:
How to make a modulo operation in objective-c / cocoa touch?
(2 answers)
Closed 7 years ago.
I have reviewed same types of questions over stack overflow but this is different. Here i want to modulo double value with integer. And compiler is giving below error.
I need to get modulo value of scrollview content offset. For that i have written below code but it is giving me error 'Invalid operands to binary expression ('CGFloat' (aka 'double'))'. Any one please help.
scrollView.contentOffset.x % 1024.00;
Thanks in advance.
The Modulo operator % works only with integers.
You could cast the value(s) to int.
(int)scrollView.contentOffset.x % 1024;
You should use fmod(). Manpage.
CGFloat remainder = fmod(scrollView.contentOffset.x, 1024.00);

How to calculate logarithm in iOS? [duplicate]

This question already has answers here:
How do I calculate a logarithm in iOS? [duplicate]
(3 answers)
Closed 9 years ago.
I need to calculate Log (base 10) and Log (base e – Naperian/Natural).
I am now assuming that Log (base 10) is:
double log10 ( double );
And am I correct to assume that Log (base e – Naperian/Natural) is just:
double log ( double );
Thanks
Check man 3 log for man page. In iOS 6 there is also vecLib which has logarithmic functions.

Resources