numbers

Toad truncating/rounding large Oracle numbers?

We have a table with a 'price' field of type NUMBER(20,7).. In TOAD I do this: update mytable set price = 1234567890123.1234567; Then I do this select: select price, to_char(price) from mytable PRICE TO_CHAR(PRICE) 1234567890123.12 "1234567890123.1234567" Question is, why does TOAD truncate the result when displayi...

Binary to ternary representation convertion

Hi, Does anybody know (or may point to some source to read about) a method or algorithm to convert a number represented in binary numeral system into the ternary one (my particular case), or universal algorithm for such conversions? The solution I've already implemented is to convert a number to decimal first and then convert it into r...

Using the boost random number generator with OpenMP

I would like to parallelize my boost random number generator code in C++ with OpenMP. I'd like to do it in way that is both efficient and thread safe. Can someone give me pointers on how this is done? I am currently enclosing what I have below; this is clearly not thread safe since the static variable in the sampleNormal function is like...

Format number as ranking position

Possible Duplicate: Is there an easy way in .NET to get st, nd, rd and th endings for numbers? Is there anything already built into C# that formats a number as a ranking position? By "ranking position" is mean one of ["st","nd,"rd","th"] eg : (1st, 2nd, 3rd, 4th). I know it'd be easy to write an extension for this, I'm just ...

How to match the numeric value in a regular expression?

Okay, this is quite an interesting challenge I have got myself into. My RegEx takes as input lines like the following: 147.63.23.156/159 94.182.23.55/56 134.56.33.11/12 I need it to output a regular expression that matches the range represented. Let me explain. For example, if the RegEx receives 147.63.23.156/159, then it needs to ...

Objective C - Number to String and Grab length inconsistencies

I am trying to grab a number from a text box entry, convert it to string and grab the length of it. (IE: Perform a LEN(someInteger) on a number). I have been able to get it working, however there are some inconsistencies when the number is 0 or null. For example; -(IBAction)update { // inputField is the number pad textbox doubl...

What are the ways to do numeric testing in bash?

Suppose I have variable "x" in bash. How can I test if it's some number? I tried if x=5; then echo "it is 5"; fi but that doesn't work, then I tried if x==5; then echo "it is 5"; fi but that also doesn't work, then I tried if [x==5]; then echo "it is 5"; fi but that also doesn't work, then I tried if [[x==5]]; then echo "it is 5"; fi...

Haskell Int and Integer

Hello, What in Haskell differs from Int ant Integer? In what documentation can i find such things? Thank you ...

Algorithm for determining largest set of successively evenly spaced value of numbers in a sorted array?

For example, in the input array [0,1,4,6,8,9,12] the largest set of successively evenly spaced numbers is {0,4,8,12} and the next largest that isn't a subset of the largest is {4,6,8}. ...

Number in python - 010

When using the interactive shell: print 010 I get back an 8. I started playing around using other numbers having zeroes before (0110 = 72, 013 = 11) but I could not figure it out... What is going on here? ...

check NaN number

Hi, is it possible to check if a number is NaN or not? UPDATE: my mistake. fixed the Question. ...

Python: most pythonic way to check if an object is a number

Given an arbitrary python object, what's the best way to determine whether it is a number? Here is is defined as acts like a number in certain circumstances. For example, say you are writing a vector class. If given another vector, you want to find the dot product. If given a scalar, you want to scale the whole vector. Checking if some...

Comparing negative numbers in javascript

I'm sure this is a simple problem, but I'm comparing negative numbers in javascript i.e.: var num1 = -83.778; var num2 = -83.356; if(num1 < num2) { // Take action 1 } else { // Take action 2 } This script will always take action 2, even though num1 is less than num2. Whats going on here? ...

Printing the Largest Prime Factor of a Composite Number in C

I was solving a puzzle, where im required to find the largest Prime Factor of a composite number entered by the user. I thought of something and have tried it out, but it doesn't manage to detect the largest prime factor amongst the factors of the composite number. I'm appending my code below, I'd be grateful if anyone could help me out...

Filtering out a number at the start of a string which has a certain pattern.

Hi, I'm trying to filter a number out of a string if that string starts with @. Here's what I thought would do the trick, but it returns nothing more than a blank page. (May contain lots of mistakes as I'm new to PHP.) <?php $String = "@1234 Hello this is a message."; $StringLength = 1; Echo "Filtering the number after the @ out of " ...

IE6-7 error with jquery

IE6 and 7 return a js error "expected identifier, string or number" on this : function fadeopacity (){ var opacity = $("#pics_list > li:first").css("opacity"); $("#pics_list > li").hover( function () { $(this).stop().animate({ opacity: 1, }, 300, null)}, ->this is the l...

in python how do I convert a single digit number into a double digits string?

So say i have a = 5 i want to print it as a string '05' ...

Finding frequent sequence of numbers in an array

Array (3, 5, 1, 3, 5, 48, 4, 7, 13, 55, 65, 4, 7, 13, 32) the frequent sequence of numbers will be (3, 5) f=2 + (4, 7, 13) f=2 any Algorithm or Pseudo code to find that ? Update(1): if (7, 13) also occurrence it will be included in the longest one by update its frequency so (4, 7, 13) f=3 and so on... Update(2): in case of (1,2,...

Convert a number from Base B1 to Base B2 without using any intermediate base.

Hey Guys Is there a way Convert a number from Base B1 to Base B2 without using any intermediate base. Ex: 214 from base 5 to base 16 without converting it first to decimal and then decimal to hexadecimal. -- Thanks Alok Kr. ...

Determine if a file has more than X lines?

Hi there, as I was not able to find a function which retrieves the amount of lines a file has, do I need to use $handle = fopen("file.txt"); For($Line=1; $Line<=10; $Line=$Line+1){ fgets($handle); } If feof($handle){ echo "File has 10 lines or more."; }Else{ echo "File has less than 10 lines."; } fclose($handle) or something si...