AutoMathic Posted November 18, 2017 Share Posted November 18, 2017 Hi, can I divide a number without the reminder? For example I have a $number = 9587 and I need to know how many thousands it is (the result should be 9). The reason is I want to refine the output like this: $Number = 9578 $Output = Round($Number/1000) & "." & Mod($Number, 1000) Msgbox (0, "Result:", $Output) Due to rounding the result looks like this: "10.587" but it should be like "9.587". Thank you. Link to comment Share on other sites More sharing options...
kylomas Posted November 18, 2017 Share Posted November 18, 2017 AutoMathic, Like Msgbox (0, "Result:", stringformat('%04.3f',$number/1000)) ? kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
Malkey Posted November 18, 2017 Share Posted November 18, 2017 A few more methods. $Number = 9578 $Output = Round($Number / 1000, 5) ; Round ( expression [, decimalplaces] ) ; Or $Output1 = Int($Number / 1000) & "." & Mod($Number, 1000) ;Or $Output2 = $Number / 1000 MsgBox(0, "Result:", $Output & @CRLF & $Output1 & @CRLF & $Output2) Link to comment Share on other sites More sharing options...
mikell Posted November 18, 2017 Share Posted November 18, 2017 Msgbox(0,"", StringRegExpReplace(9578, '(?=\d{3}$)', ".")) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now