CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

# Thread: mathematical equation implmentation in c++

1. Member Join Date
May 2015
Posts
316

## mathematical equation implmentation in c++

Hello,

I need to implement the following math conversion in the c++. I am looking for simple function. Could you help me with this., I am not much aware of the maths functionalities available in c++

1. Need to convert dBns to ns and the in the xml requirements, I see the formula as : 10^(0.8 * x)

2. Other conversion is similar(mBradians to radians) : 10 ^ (0.001 * x)
Then I need the convert the radians to degrees

Thanks a lot
pdk
Last edited by pdk5; April 30th, 2020 at 07:16 AM.  Reply With Quote

2. ## Re: mathematical equation implmentation in c++  Reply With Quote

3. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++ Originally Posted by VictorN DeciBel nano Secs to Nano Secs. It may not be much relevance as the conversion formula is shown above .
I just want to implement the conversion formula in c++  Reply With Quote

4. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++

And the conversion formula is in the excel. Any idea, the symbol "^" mean in excel ?
It is very help ful if I get this info as soon as possible as I have release next week !   Reply With Quote

5. ## Re: mathematical equation implmentation in c++

It is the same as function power()  Reply With Quote

6. ## Re: mathematical equation implmentation in c++

For C++, use pow() function instead of ^ http://www.cplusplus.com/reference/cmath/pow/

so 10 ^ (0.8 * X) becomes pow(10, 0.8 * X). And similar for the other.

To convert radians to degrees (and vice versa), always remember that 360 deg = 2 * pi radians. So 1 radian is 360 / (2 * pi) degrees which is 180 / pi degrees. So y radians are y * 180 / pi degrees.

To get the value of pi without having to define a constant, use the value of M_PI as explained in https://docs.microsoft.com/en-us/cpp...s?view=vs-2019  Reply With Quote

7. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++

Thankyou very much Kaud. Very helpful .  Reply With Quote

8. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++

Another doubt generic not c++ :
To convert nsDb to ns, the formula given is dBns to ns : 10^(0.8 * x) .

From the look of it, it does not look right ?

Because the other formula, (mBradians to radians) : 10 ^ (0.001 * x) looks ok, because the mB = .001 Bell

my maths skills have been rusty, so very helpful to get some inputs here. Last edited by pdk5; May 1st, 2020 at 09:42 AM.  Reply With Quote

9. ## Re: mathematical equation implmentation in c++

decibel - or bel - has got not nothing to do with time or angles and everything to do with power ratios. radians/degrees has got nothing to do with (deci)bel. A decibel is 1/10 of a bel.

See https://en.wikipedia.org/wiki/Metric_prefix for a list of SI prefixes.

To do a conversion from one type to another, they must be a mathematical relationship between them. ie there is one between radians and degrees, but not between decibel and sec(ond)s.

What are you trying to do? You said in post #3 that you had the formulas and all you needed was help implementing them? If the formulas are now not correct, you need to determine what the original number represents in terms of a unit (mass, length, time etc) and its prefix. Then determine what the required number is to represent. Once you know that, then the required conversion formula can be obtained.  Reply With Quote

10. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++

Thanks a lot kaud , for the reply . These formulas are provided in requirements. But req are in initial stages and may not be correct.

The formula I showed above , 10^(0.8 * x) , is to convert "nanoSecond DB" to "nanosecond" ? Looks incorrect and even sample values were coming very high. so I am thinking it may be some typo in requirements ?
Last edited by pdk5; May 1st, 2020 at 02:34 PM.  Reply With Quote

11. ## Re: mathematical equation implmentation in c++

If DB is for Decibel, then nanoSecond Decibel is a nonsense. A nano Decibel would make sense which would be 10 ^ -10 Bel. But in physical terms, that's such a very low power level that something doesn't seem right.

Where are these formulas coming from? What exactly are you trying to do?  Reply With Quote

12. Member +  Join Date
Feb 2017
Posts
566

## Re: mathematical equation implmentation in c++ Originally Posted by pdk5 To convert nsDb to ns, the formula given is dBns to ns : 10^(0.8 * x) .

From the look of it, it does not look right ?

Because the other formula, (mBradians to radians) : 10 ^ (0.001 * x) looks ok, because the mB = .001 Bell
Note that there's a slight difference of notation between dBns and mBradians.

It's easier to see if you rewrite these like dB(ns) and mB(radians). The first would be the dB value corresponding to a ratio relative to 1 nanosecond. The second would be the mB value corresponding to a ratio relative to 1 radian. It could explain why the formulas do not conform logically.
Last edited by wolle; May 2nd, 2020 at 05:06 AM.  Reply With Quote

13. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++ Originally Posted by 2kaud If DB is for Decibel, then nanoSecond Decibel is a nonsense. A nano Decibel would make sense which would be 10 ^ -10 Bel. But in physical terms, that's such a very low power level that something doesn't seem right.

Where are these formulas coming from? What exactly are you trying to do?
- The "nanosec DB" is the unit received for the Delay spread in the LTE/5g at a pixel from the basestation. In our tool, they want to display with the unit of microseconds. rather than nanosec DB. I have not much worked on Physical layer stuff. But even then , this unit looks bit odd for me. I mean to use DB on nanosecs ?

- And the other unit is from "mBradians" to "radians" is for the Angular spread data .
Last edited by pdk5; May 2nd, 2020 at 07:41 AM.  Reply With Quote

14. Member +  Join Date
Feb 2017
Posts
566

## Re: mathematical equation implmentation in c++

... continuing from #12:

The second formula would be

x = 1000 * log(ratio) // mB formula

=>

ratio = 10 ^ (x/1000)

so it looks right.
Last edited by wolle; May 3rd, 2020 at 07:50 AM.  Reply With Quote

15. Member Join Date
May 2015
Posts
316

## Re: mathematical equation implmentation in c++ Originally Posted by wolle The second formula would be

x = 1000 * log(ratio)

=>

ratio = 10 ^ (x/1000)

Thanks , but whatabout the first one ?   Reply With Quote

c++, mathematics #### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
• 