Jump to content
Sign in to follow this  
goldenix

[Solved]_5,9 == 6

Recommended Posts

goldenix

Is ther an easier way? a built in func?

How do you determine is X 1 or 2 if the value is 0,5 ? is there maybe a standard or something?

$x = '1.9'

$array = StringSplit($x, '.', 1)

If $array[2] >= 5 Then $x = $array[1] + 1
    
ConsoleWrite($x & @CRLF)

EDIT: Solution is ROUND($X,0) because I want no decimal places

Edited by goldenix

My Projects:[list][*]Guide - ytube step by step tut for reading memory with autoitscript + samples[*]WinHide - tool to show hide windows, Skinned With GDI+[*]Virtualdub batch job list maker - Batch Process all files with same settings[*]Exp calc - Exp calculator for online games[*]Automated Microsoft SQL Server 2000 installer[*]Image sorter helper for IrfanView - 1 click opens img & move ur mouse to close opened img[/list]

Share this post


Link to post
Share on other sites
weaponx

Here is one way to separate the integer and fraction parts of a number.

$x = 1.9

$Integer = Int($x)
$Fraction = $x-$Integer

MsgBox(0,"","Integer: " & $Integer & @CRLF & "Fraction: " & $Fraction)

Share this post


Link to post
Share on other sites
NBJ

@goldenix

are you looking to round up your numbers?

try: Ceiling Returns a number rounded up to the next integer.

Ceiling ( expression )

eg

$x = Ceiling(1.9)
ConsoleWrite($x & @CRLF)

You can also look at Round(), Floor(), Int()

Hope thats what you are after

Cheers

NBJ

edit: reference to Floor() Round() Int()

edit: after re reading again i I think you are after :

ROUND($X,0)

Edited by NBJ

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×