Jump to content

Question Var Output


Recommended Posts

I have a question About the Output from a Var which looks like :     34.32132312321   

How to make it work that it looks like :      34.321

I already searched through some AutoIt Includes >.< I hope somebody can help by this

$Byte = InetGetSize(http://download853.mediafire.com/albf2b2g21bg/6tkd4gb68qdb7hd/Anime+Pics.rar,0);Download Size in Byte(Just an old Pic File)
    
    If $Byte > 1024 Then
        
    $Kilobyte = $Byte / 1024;Converting Byte to Kilobytes
        
        If $Kilobyte > 1024 Then
            
        $Megabyte = $Kilobyte / 1024;Converting Kilobyte to Megabyte
            
            If $Megabyte > 1024 Then
                
            $Gigabyte = $Megabyte / 1024;Converting Megabyte to Gigabyte
            
                If $Gigabyte > 1024 Then
                
                $Terabyte = $Gigabyte / 1024;Converting Gigabyte to Terabyte
                
                    If $Terabyte > 1024 Then
                    
                    $Petabyte = $Terabyte / 1024;Converting Terabyte to Petabyte
                    
                        If $Petabyte > 1024 Then
                            
                            $Exabyte = $Petabyte / 1024;Converting Petabyte to Exabyte
                            $_SIZE1 = $Exabyte & " EB"
                            
                        ElseIf $Petabyte < 1024 Then
                            
                            $Petabyte = $Terabyte / 1024
                            $_SIZE1 = $Petabyte & " PB"
                            
                        EndIf
                        
                    ElseIf $Terabyte < 1024 Then
                    
                    $Terabyte = $Gigabyte / 1024
                    $_SIZE1 = $Terabyte & " TB"
                    
                    EndIf
                
                ElseIf $Gigabyte < 1024 Then
                
                $Gigabyte = $Megabyte / 1024
                $_SIZE1 = $Gigabyte & " GB"
                
                EndIf
                
            ElseIf $Megabyte < 1024 Then
                
            $Megabyte = $Kilobyte / 1024
            $_SIZE1 = $Megabyte & " MB"
                
            EndIf
            
        ElseIf $Kilobyte < 1024 Then
            
        $Kilobyte = $Byte / 1024
        $_SIZE1 = $Kilobyte & " KB"
            
        EndIf
        
    ElseIf $Byte < 1024 Then
    
    $_SIZE1 = $Byte & " Bytes"
    
EndIf

MsgBox(52,"Title","Size is: " & $_SIZE1)

 

  • C++/AutoIt/OpenGL Easy Coder
  • I will be Kind to you and try to help you
  • till what you want isn't against the Forum
  • Rules~

 

Link to comment
Share on other sites

So you just want to strip off the exceeding decimal places?
Or should 34.32152312321 be rounded to 34.322?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Then please have a look at function Round.

ConsoleWrite(Round(34.32152312321, 3) & @CRLF)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

Use the Round function, and specify the number of decimal places

$Num = 34.32152312321
ConsoleWrite(Round($Num, 3) & @CRLF)

 

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
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
 Share

×
×
  • Create New...