• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 209
  • Last Modified:

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

I need to convert 1.0000001 (real) to 1 (int). Is ther a way in perl ? Thanks
0
oualide
Asked:
oualide
  • 5
  • 4
1 Solution
 
b2piCommented:
$a = 1.0000001;
$a = int($a);

0
 
waleed072098Commented:
what if the $a contains binary data ?
how to convert from binary to real and int
Thanks
0
 
b2piCommented:
What do you mean by 'binary' data?
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

 
waleed072098Commented:
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
 
b2piCommented:
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
 
b2piCommented:
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
 
waleed072098Commented:
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
 
waleed072098Commented:
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
 
waleed072098Commented:
To b2pi

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


0
 
ozoCommented:
Are you asking about binary data as in
perldoc -f pack
If so, you'll have to know the format of the data
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now