Parameters in UpdateTip - calculation of log2_work


FYI the code under discussion is available here on GitHub.

-> is a member access operator in C++, just as . is. They both expect the name of an object's member on the right (e.g. a member function or variable). The difference is that . expects an object on the left, whereas -> expects a pointer to an object which it first dereferences.

So chainActive.Tip()->nChainWork.getdouble() starts with the active chain, gets a pointer to a CBlockIndex object which represents the current tip, dereferences that pointer and gets the total chain work of the tip (which is a 256 bit integer), and converts it to a double.

Next it calculates natural_log(total_chain_work) / natural_log(2), which is the same as calculating log_base_2(total_chain_work). I presume this is simply to make the output smaller, as opposed to having to output the entire (much longer) total_chain_work.

If you'd like to get it back into the total_chain_work format used in older versions, just...

0 0

Logarithm of a number is the power to which the base must be raised in order to produce this number. Logarithm with base 10 is called a common logarithm and denoted as “log.” For example, log1000 would be 3, as 10 raised in the power of 3 produces 1000. Every scientific calculator has a built-in function to calculator log of any number (typically the button “log”). But none can calculate log2, which is logarithm with base 2, directly. As an example, calculate log2 of the number “12” i.e. log2(12).

Express log2(Y) of any number Y via logY. According to the logarithm definition Y=2^(log2(Y)). Take log of both sides of the equation to get logY=log(2^(log2(Y))=log2(Y) x log2. Then divide both sides by “log2” to get Log2(Y)=log(Y)/log2.

Calculate log2 with a calculator. Enter “2” and press the “log” button. log2=0.30103. Write down this constant as it will be used in all calculations of log2.

Calculate logY . Enter a number and press the “log” button. In our...

0 0

The class template in determines the position of the highest bit in a given value. This facility is useful for solving generic programming problems.

namespace boost { typedef implementation-defined static_log2_argument_type; typedef implementation-defined static_log2_result_type; template struct static_log2 { static const static_log2_result_type value = implementation-defined; }; template < > struct static_log2< 0 > { }; }

The boost::static_log2 class template takes one template parameter, a value of type static_log2_argument_type. The template only defines one member, value, which gives the truncated, base-two logarithm of the template argument.

Since the logarithm of zero, for any base, is undefined, there is a specialization of static_log2 for a template argument of zero. This specialization has no members, so an attempt to use the base-two logarithm of zero results in a compile-time error.


0 0
0 0
0 0

The TipCalculator app broke in iOS 4 because of a subtle change Apple made to how UITextFields work. Under iOS 4, when we tell billField to become the first responder (and make the keyboard come up), nothing happens because it has the "User Interaction Enable" property disabled. Previously in iOS 3, this was not the case.

The simplest way to make the app work is enable that property (in MainWindow.xib, select billField and open the Inspector. Check "User Interaction Enabled"). However, this will let the user change the cursor in billField manually, which is undesirable.

Here are some steps to make TipCalculator work under iOS 4, while still maintaining full functionality:

1) Open MainWindow.xib and make a duplicate of the top UITextField and move it to the bottom of the screen. Open the Inspector, and check "User Interaction Enabled" and "Hidden" for the new UITextField.

2) In the "Connections" tab of the Inspector, remove the "Editing Changed"...

0 0
0 0

Handling Iterative Calculations With Ease

Though it is usually preferable to avoid circular references, they will appear occasionally when building complex calculations. One common example is in tax accrual calculations, where federal income tax is deductible on state tax returns. Here, since federal tax is deductible on the state return, and state tax is deductible on the federal return, a circular reference exists by the very nature of the calculation. By default, Excel treats such calculations as errors. In this tip, you will learn how to enable circular, or iterative, calculations.

An iteration is repeatedly recalculating a worksheet until a specific numeric condition is met. Excel cannot calculate a formula that refers to the cell – either directly or indirectly – that contains the formula. This is called a circular reference and circular references, by default, can iterate indefinitely, leading to errors in worksheets, as shown in Figure 1.

0 0

This chapter explains how to use Discoverer Plus Relational parameters to answer typical business questions, and contains the following topics:

What are parameters?

Parameters are workbook items that allow Discoverer users to analyze worksheets by entering dynamic input values (see figure below). Input values are typically used to:

provide input to conditions that are used to filter worksheets - for example, when a workbook or worksheet is opened or refreshed, the parameter is used to first ask the worksheet user 'What month do you want to analyze?'. A worksheet user can choose to look at data for the month of January only.

provide input to calculations - for example, a worksheet user can enter the value '3' when prompted, which is then used to divide data into three bands using a predefined calculation containing a banding function (see "About using parameters to collect dynamic user input")

What are the benefits of using parameters?...

0 0

In the Calculation parameters form, if Working time is registered during a period in which the profile specification type Overtime is set up in the work time profile, after the time is calculated, it is included in Standard time, Pay time and Pay overtime.

When paid time is calculated, pay is generated from pay agreement lines in the pay agreement regarding the following wage types:

Standard time (= Pay time)

Overtime (= Pay overtime)

Premiums (If any premiums are set up in the pay agreement used to calculate the worker’s pay)

This means that when a worker works overtime, the worker receives the standard pay plus an overtime bonus plus premiums (for example, an operation- or task-related bonus, or a seniority...

0 0

DAX is the new language used by PowerPivot and Analysis Services in Tabular mode and it resembles the syntax of Excel formula and it can be considered a functional language. You do not have iterative statements, but you can run iterative functions like, for example, SUMX and FILTER. The most important functions in DAX are CALCULATE and CALCULATETABLE, and these functions are also the most complex to master, because of the many operations they do. In order to fully understand them, you also have to well understand evaluation contexts (row context and filter context).
The general idea is that these functions transform a row context (if exists) into a filter context, which is automatically propagated to related tables, then modify the filter context according to the parameters passed after the first one, and finally evaluate the expression passed as first parameter in the resulting modified filter context.

If you read the previous description carefully, you will discover...

0 0

I'm getting various types of database corruption errors (mostly just like this one) when trying to synchronize bitcoin-qt after quite a long time (~one year) without running it. One of the failures even broke my wallet.dat (no idea how that could happen) to the point where I had to restore it from backups.

The machine runs Btrfs, so silent data corruption is highly unlikely. (Btrfs is a checksummed filesystem, just like ZFS.) The machine doesn't have any software issues other than the bitcoin problem and passes days of memtesting without failure.

BTW, --reindex doesn't solve the problem; it simply fails again sooner or later in the reindexing process. The only thing that does help is bitcoin-qt -reindex -rpcthreads=1. This leads me to believe that there's an ugly race condition lurking somewhere in bitcoin and/or bitcoin-qt.

However, I don't know why the tweak above helped and whether it was just a coincidence, because IIUC, the -rpcthreads option would only...

0 0
0 0