Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: How to transform floating-point data type to integer data type?  (Read 2679 times)

0 Members and 1 Guest are viewing this topic.

Lion

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 101
    • View Profile
How to transform floating-point data type to integer data type?
« on: September 07, 2006, 10:07:51 AM »

How to transform floating-point data type to integer data type?

var ttt = 250 / 10;  (floating-point data type)

var fff = ttt; (integer data type) ????
Logged

Jerrot

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 690
    • View Profile
Re: How to transform floating-point data type to integer data type?
« Reply #1 on: September 07, 2006, 11:14:27 AM »

Hi Lion,

hmm, I don't understand neither your example nor your goal.
250 / 10 is 25, why should it be float?

Anyway, WME Script uses these types internally, but in most cases you shouldn't have to care about it. So what do you need exactly?

Another example would be:

Code: [Select]
var myFloat = 100 / 3;Now that would internally be a float for sure. To get the result "33", you might use:

Code: [Select]
var myInt = Math.Floor(myFloat);which cuts off everything behind the comma.
Logged
Mooh!

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: How to transform floating-point data type to integer data type?
« Reply #2 on: September 07, 2006, 11:39:05 AM »

Also there are the ToInt(), ToFloat(), ToBool() and ToString() global functions.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave

Lion

  • Regular poster
  • ***
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 101
    • View Profile
Re: How to transform floating-point data type to integer data type?
« Reply #3 on: September 07, 2006, 12:36:00 PM »

Thanks
Logged
 

Page created in 0.042 seconds with 24 queries.