mirror of
https://github.com/boostorg/integer.git
synced 2025-11-05 02:31:38 +01:00
Added examples in /example folder (contain snippets for Quickbook), and updates to add typedef static_gcd_t for common factor
This commit is contained in:
41
example/integer_log2_example.cpp
Normal file
41
example/integer_log2_example.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
// boost integer_log2_example.cpp
|
||||
|
||||
// Copyright Paul A. Bristow 2015
|
||||
// Use, modification and distribution are subject to the
|
||||
// Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt
|
||||
// or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Caution: this file contains Quickbook markup as well as code
|
||||
// and comments, don't change any of the special comment markups!
|
||||
|
||||
//[integer_log2_example_0
|
||||
#include <boost/integer/static_log2.hpp> // For boost::static_log2
|
||||
//] [/integer_log2s_example_0]
|
||||
#include <iostream>
|
||||
#include <limits> // for numeric_limits min and max.
|
||||
|
||||
//[integer_log2_example_
|
||||
//] [/integer_log2s_example_]
|
||||
|
||||
int main()
|
||||
{
|
||||
//[integer_log2_example_1
|
||||
int n = boost::static_log2<256>::value;
|
||||
//] [/integer_log2_example_1]
|
||||
|
||||
std::cout << n << std::endl; // 8
|
||||
|
||||
//[integer_log2_example_2
|
||||
int n2 = boost::static_log2<65536>::value;
|
||||
//] [/integer_log2_example_2]
|
||||
|
||||
std::cout << n2 << std::endl; // 16
|
||||
|
||||
} // int main
|
||||
|
||||
/*
|
||||
//[integer_log2_example_output
|
||||
8
|
||||
//] [/integer_log2_example_output]
|
||||
*/
|
||||
Reference in New Issue
Block a user