
April 30th, 2020, 07:12 AM
#1
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.

April 30th, 2020, 07:26 AM
#2
Re: mathematical equation implmentation in c++
What is dBns? ns? mBradians?
Victor Nijegorodov

April 30th, 2020, 07:53 AM
#3
Re: mathematical equation implmentation in c++
Originally Posted by VictorN
What is dBns? ns? mBradians?
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++

April 30th, 2020, 08:14 AM
#4
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 !

April 30th, 2020, 08:24 AM
#5
Re: mathematical equation implmentation in c++
It is the same as function power()
Victor Nijegorodov

April 30th, 2020, 10:10 AM
#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/enus/cpp...s?view=vs2019
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only  not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums  and not via private messages!
C++17 Compiler: Microsoft VS2019 (16.7.4)

April 30th, 2020, 10:15 AM
#7
Re: mathematical equation implmentation in c++
Thankyou very much Kaud. Very helpful .

May 1st, 2020, 09:33 AM
#8
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.

May 1st, 2020, 11:54 AM
#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.
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only  not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums  and not via private messages!
C++17 Compiler: Microsoft VS2019 (16.7.4)

May 1st, 2020, 01:48 PM
#10
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.

May 2nd, 2020, 03:39 AM
#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?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only  not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums  and not via private messages!
C++17 Compiler: Microsoft VS2019 (16.7.4)

May 2nd, 2020, 04:46 AM
#12
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.

May 2nd, 2020, 04:56 AM
#13
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.

May 2nd, 2020, 05:05 AM
#14
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.

May 2nd, 2020, 05:07 AM
#15
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 ?
Tags for this Thread
Posting Permissions
 You may not post new threads
 You may not post replies
 You may not post attachments
 You may not edit your posts

Forum Rules

Click Here to Expand Forum to Full Width
OnDemand Webinars (sponsored)
