Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Getting a number without numbers AFTER decimals?

Asked by
iFlusters 355 Moderation Voter
8 years ago

Sorry for the bad question, but really simply how do this..:

number = 1.9999
--change
print(number)

Will print 2 rather than 1.9999.. etc

So how do I get a singular number without its decimals.

2 answers

Log in to vote
2
Answered by 8 years ago

Wouldn't a simple math.floor() do the job?

0
I like this answer the most. 0xDEADC0DE 310 — 8y
0
0
Haven't been on a while, sorry. IlluminatiCat 15 — 8y
0
When a number ends in e-007, it means that the number is 7 decimal places smaller than it really is. For example, your first number 4.768371e-007 means that the number's true value is 0.0000004768371. It is a common bug found in roblox. IlluminatiCat 15 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

You need to define the type to use.

Here is the script I used:-

local a = 4.0342
print(tonumber(string.format("%d",a))) -- %d defines the type 

this uses string formatting to only take the number and not the decimals, then converts back to a number.

Hope this helps

Sorry I don't have time to find a list of data types.

Answer this question