Solved

How to convert a real number to int ???????

Posted on 1998-10-22
10
192 Views
Last Modified: 2010-03-05
I need to convert 1.0000001 (real) to 1 (int). Is ther a way in perl ? Thanks
0
Comment
Question by:oualide
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 5

Accepted Solution

by:
b2pi earned 100 total points
ID: 1205620
$a = 1.0000001;
$a = int($a);

0
 

Expert Comment

by:waleed072098
ID: 1205621
what if the $a contains binary data ?
how to convert from binary to real and int
Thanks
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205622
What do you mean by 'binary' data?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Expert Comment

by:waleed072098
ID: 1205623
When you open a binary file with binmode (Filehandler),
you recive the data in $var when reading.
But to process such a data (say you want to add 1 to $var) you to convert to some other type. if you know the answer please let me know. thanks alot
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205624
perl autoconverts (or, as it says in the FAQ, 'does the right thing');

For instance:

$a = "2.00";
$b = $a + 1.0;
$c = $b -1;

if ($a == $b) {
   print "What a wonderful world";
} else {
   print "Uhoh... what happened?";
}
print "\n";
0
 
LVL 5

Expert Comment

by:b2pi
ID: 1205625
By the way, waleed, you have 3 questions locked right now, and your grading history shows a habit of letting questions auto-grade, which is oft considered impolite.  Perhaps you could acknowledge those 3 questions?
0
 

Expert Comment

by:waleed072098
ID: 1205626
b2pi,

I am very very polite my friend. I don't mean that and I will check to see what you talinkg about. That's not my habit but sometimes they send the evaluation with wrong answer and because I am SO polite I don't reject it so fast. I let them read the comments until they might understand the question and give an appropriate answer. You see how I am not rude. Anyway I thank you for that "impolite thing".
0
 

Expert Comment

by:waleed072098
ID: 1205627
To b2pi

Look at this and the answers. They send a respond something like  
Can we convert to GIF and keep z's values"
Digiwiz proposes something has no relation with what I want and he posts the evaluation!!!!!!!!!!
Jacco propses the solution and disappears since july 98 .

Who is polite ??????


0
 

Expert Comment

by:waleed072098
ID: 1205628
To b2pi

The remaining 2 questions are new even very new. One of them today and the other one is of last week.


0
 
LVL 84

Expert Comment

by:ozo
ID: 1205629
Are you asking about binary data as in
perldoc -f pack
If so, you'll have to know the format of the data
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SIMPLE Perl Regex 1 164
Perl Script - Remove row of data based on column value 3 76
collecting information 2 203
Union rows in array that have common elements (Part 2) 4 86
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question