generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: String Manipulation

Previous Thread :: Next Thread 
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
14 Dec 2016 06:58 PM
I'm new to advanced string manipulation, so wiki links would be appreciated when answering :)

I'm trying to make a program to count the significant figures in a number, 304 has 3 significant figures, 0.03 have 1 significant figure, etc. As far as I know, there's no function to count significant figures, so does anyone have ideas for how to go about this? I don't want a program, just a method, or a helpful wiki link.
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
14 Dec 2016 06:59 PM
significant figures? mind defining that

Formerly ToxicDominator - add 30,319 posts
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 06:59 PM
(string.find(input, '.') or string.len(input) - 1)

Assuming it's always a number. I haven't actually tested this, sorry.
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:00 PM
((string.find(input, '.') or string.len(input)) - 1)

sorry, this one. i had made an error with precedence i think
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:02 PM
whoops

function SFigures(input)
return ((string.find(input, '%.') or string.len(input)) - 1)
end
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:03 PM
jesus i'm posting too fast sorry for not checking the actual freaking output of my code

function SFigures(input)
return string.find(input, '%.') and string.find(input, '%.') - 1 or string.len(input)
end
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
14 Dec 2016 07:03 PM
####################################################################################################################################################################################
Report Abuse
AggressiveCatch is not online. AggressiveCatch
Joined: 17 Jul 2011
Total Posts: 5840
14 Dec 2016 07:06 PM
@guy who posted somewhere above me

i think significant figures = significant digits

u can google that if u dont know what it is
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
14 Dec 2016 07:07 PM
@Unsub google significant figures, can't post a link :(

@Real That's not what I'm looking for, again, google significant figures. If I run SFigures(100) it returns 3, which is incorrect, 100 has 1 significant figure.

Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:11 PM
function SFigures(input)
local s,e = input:find("[1-9][%d%.]*[1-9]*")
return e - s + (input:sub(s,e):find('%.') and 0 or 1)
end

I've got no idea if this is what you're looking for.
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:12 PM
By significant figures, do you mean the figures that would need to be expressed when writing a number in scientific notation?

I'm kind of lost here.
Report Abuse
caca50 is not online. caca50
Joined: 10 Jul 2011
Total Posts: 2037
14 Dec 2016 07:20 PM
There are three rules on determining how many significant figures are in a number:


Non-zero digits are always significant.

Any zeros between two significant digits are significant.

A final zero or trailing zeros in the decimal portion ONLY are significant.



Roblox.Forum.Scripters:1: bad argument #1 to 'intellect' (number expected, got nil)
Report Abuse
ExtremeBuilder15 is online. ExtremeBuilder15
Joined: 01 May 2012
Total Posts: 3176
14 Dec 2016 07:20 PM
Significant figures are defined by a few rules:

1. All nonzero digits are significant. (1-9)

2. All 0's after the decimal point and after a nonzero digit are significant (3.00 has 3 sig figs)

3. All 0's between two significant figures are significant (100 has 1 significant figure but 100.0 has 4. 1 is a significant figure, and the .0 is after a decimal and after a nonzero number so it is significant, the two zeros in between are significant because of this.)

Google it if you don't understand
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:41 PM
function SD(input)
if type(input) == 'number' then input = '' .. input end
s,e = input:find("[1-9]-%.*%d*")
return (e - s) + (input:sub(s,e):find('.') and 0 or 1)
end

i think i did it
Report Abuse
Real_Spooky is not online. Real_Spooky
Joined: 23 Oct 2013
Total Posts: 3149
14 Dec 2016 07:43 PM
goddamn it no i didn't
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image