Floats to Integers 
Author Message
 Floats to Integers

Can I convert a Float into an Integer.

Example:
    a := 18.13

    and I would like to get b := Integer a := 18.

--
Angel Belda Cspedes
Tlf: (96)580 23 05 y (96)580 44 34
Fax: (96)580 81 71



Wed, 18 Jun 1902 08:00:00 GMT  
 Floats to Integers

Quote:

> Can I convert a Float into an Integer.

Yes. Try sending the message #asInteger to it.

-Eric Clayberg
President                      
Smalltalk Systems (StS), a division of Instantiations, Inc.



   Web: http://www.smalltalksystems.com
        http://www.instantiations.com

GO SMALLTALK!



Wed, 18 Jun 1902 08:00:00 GMT  
 Floats to Integers

Quote:

>Can I convert a Float into an Integer.
>Example:
>    a := 18.13
>    and I would like to get b := Integer a := 18.

 a truncated -> 18

 Marten



Wed, 18 Jun 1902 08:00:00 GMT  
 Floats to Integers


Quote:

>Can I convert a Float into an Integer.

>Example:
>    a := 18.13

>    and I would like to get b := Integer a := 18

Sure. In IBM Smalltalk these messages convert to integer; other
Smalltalks should do the same:

   a asInteger      Rounds to the nearest integer
   a rounded        Rounds to the nearest integer
   a floor          Next lowest integer
   a truncate       Integer nearest zero
   a ceiling        Next highest integer

12.78 asInteger 13
12.78 floor 12
12.78 truncated 12
12.78 ceiling 13

-12.78 asInteger -13
-12.78 floor -13
-12.78 truncated -12
-12.78 ceiling -12

Dave

_____________________________________________
David N. Smith
IBM T J Watson Research Center, Hawthorne, NY

Home Page: http://www.dnsmith.com/
_____________________________________________
Any opinions or recommendations are those
of the author and not of his employer.



Wed, 18 Jun 1902 08:00:00 GMT  
 Floats to Integers


Odd, but my news server coughed up a whole bunch of messages from a month
ago, none of which I had seen, and showed then as brand new. I answered
several before I noted the dates. Sorry.

Dave

_____________________________________________
David N. Smith
IBM T J Watson Research Center, Hawthorne, NY

Home Page: http://www.dnsmith.com/
_____________________________________________
Any opinions or recommendations are those
of the author and not of his employer.



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Dr Scheme question: Float to integer conversion?

2. Converting string to float and integer

3. Float to Integer Conversion ?

4. floats to integers?

5. Rounding error when doing float-to-integer

6. Q: ways to convert floats to integers (fixnums)

7. Any faster way to convert float to integer than "fist"?

8. Float, integer conversions

9. floating point number into integer -JavaScript

10. integer to 32-bit float conversion

11. Looking to license integer and floating point arithmetic cores

12. strings to floats/integers

 

 
Powered by phpBB® Forum Software