Multiply a given Integer with 3.5
来源:互联网 发布:淘宝50字通用好评 编辑:程序博客网 时间:2024/06/09 07:59
reference:
http://www.geeksforgeeks.org/multiply-an-integer-with-3-5/
Problem Definition:
Given a integer x, write a function that multiplies x with 3.5 and returns the integer result. You are not allowed to use %, /, *.
Examples:
Input: 2
Output: 7
Input: 5
Output: 17 (Ignore the digits after decimal point)
Solution:
This could be done by equation (8*x – x)/2 .
Code:
int multiplyWith3Point5(int x){ return ((x<<3) - x)>>1;}
- Multiply a given Integer with 3.5
- No. 09 - Numbers with a Given Sum
- Reverse bits of a given 32 bits unsigned integer
- P31 (**) Determine whether a given integer number is prime.
- Given a roman numeral, convert it to an integer.
- LeetCode(7) Given a 32-bit signed integer, reverse digits of an integer解题报告
- Smallest subarray with sum greater than a given value
- SharePoint debug : launchPoint given is already associated with a callout
- [LinkedIn]Implement Find and replace (find given pattern and replace it with a given string)
- poj 3468 A Simple Problem with Integer
- Given an integer, write a function to determine if it is a power of two.
- Given an integer, write a function to determine if it is a power of two
- 笔试题:Suggest a simple and fast way to multiply the input integer digit by 7。
- Given a positive integer N, you should output the most right digit of N^N.
- TypeError: ufunc 'multiply' did not contain a loop with signature matching types dtype('S32')
- leetCode Given an integer (signed 32 bits), write a function to check whether it is a power of 4
- Algorithm: Reverse a Integer to an array with recursion
- A class for operations with Large Integer Numbers
- Android 应用程序之间数据共享—ContentResolver
- Mac上锁屏的快捷键设置
- ArcGIS Server REST API(收藏教程)
- 单片机之旅——拓展的IO接口8255A
- Turn off the rightmost set bit
- Multiply a given Integer with 3.5
- Windows环境下WAMP + MantisBT的架设
- SSH配置(一)-struts2(convention插件零配置)
- Add 1 to a given number
- 黑马程序员_IO(下)
- QQ大文件为何上传这么快
- JVM垃圾收集算法
- SCI简介 引文数据分析和同行评估
- Mac下更新SVN