• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

getting the lest sig fig (Math question)

Status
Not open for further replies.
Level 13
Joined
Mar 24, 2010
Messages
950
lets say i have a integer value that can range anywhere from 0-2,000,000

i want to be able to get the least sig fig
so if the number is 143,268
i want to be able to get the 8 by itself in a temp int.

what i was thinking so far as options is set it in a temp int as the length of the int holding the number and try to get it via string manipulation but its late and cant think well enough to do it lol
ill update and let ya know if i got it when i do..

I figured it out, SOLVED
 
Last edited:
Level 6
Joined
Dec 9, 2010
Messages
121
Code:
Least Significant Digit
    Events
        Player - Player 1 (Red) types a chat message containing -digit as An exact match
    Conditions
    Actions
        Set RandomInt[0] = (Random integer number between 1 and 2000000)
        Set RandomInt[1] = (RandomInt[0] mod 10)
        Game - Display to (All players) the text: (String(RandomInt[1]))

Getting the number, mod 10, will return the last digit. If you want an explanation on why this works, I'd be happy to give one. Also, the function is under Math - Modulo, in the GUI trigger editor.

Hope this helped!

Edit: Oops, I was typing the solution right as you said it was solved. My bad. xD
 
Last edited:
Status
Not open for further replies.
Top